Skip to content

Commit

Permalink
change(uploader): add --no-check to skip checks and force uploaders t…
Browse files Browse the repository at this point in the history
…o run
  • Loading branch information
l3uddz committed Apr 20, 2020
1 parent 610a5e2 commit 80c3875
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
1 change: 1 addition & 0 deletions cmd/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
var (
flagSyncer string
)

var syncCmd = &cobra.Command{
Use: "sync",
Short: "Perform syncer task(s)",
Expand Down
27 changes: 20 additions & 7 deletions cmd/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import (
"strings"
)

var (
flagNoCheck bool
)

var uploadCmd = &cobra.Command{
Use: "upload",
Short: "Perform uploader task(s)",
Expand Down Expand Up @@ -79,12 +83,15 @@ var uploadCmd = &cobra.Command{
}

// check if upload criteria met
if shouldUpload, err := upload.Check(); err != nil {
upload.Log.WithError(err).Error("Failed checking if uploader check conditions met, skipping...")
continue
} else if !shouldUpload {
upload.Log.Info("Upload conditions not met, skipping...")
continue
if !flagNoCheck {
// no check was not enabled
if shouldUpload, err := upload.Check(); err != nil {
upload.Log.WithError(err).Error("Failed checking if uploader check conditions met, skipping...")
continue
} else if !shouldUpload {
upload.Log.Info("Upload conditions not met, skipping...")
continue
}
}

// perform upload
Expand All @@ -100,6 +107,8 @@ func init() {
rootCmd.AddCommand(uploadCmd)

uploadCmd.Flags().StringVarP(&flagUploader, "uploader", "u", "", "Run for a specific uploader")

uploadCmd.Flags().BoolVar(&flagNoCheck, "no-check", false, "Ignore check and run")
}

func performUpload(u *uploader.Uploader) error {
Expand All @@ -114,7 +123,11 @@ func performUpload(u *uploader.Uploader) error {
}

/* Generate Additional Rclone Params */
additionalRcloneParams := u.CheckRcloneParams()
var additionalRcloneParams []string

if !flagNoCheck {
additionalRcloneParams = u.CheckRcloneParams()
}

/* Copies */
if len(u.Config.Remotes.Copy) > 0 {
Expand Down

0 comments on commit 80c3875

Please sign in to comment.