-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: --daisy-chain flag for sync command and standalone dedupe comma…
…nd (#27) * build: use latest goreleaser * Add systemd services * Update README.md * feat: add dedupe command --no-dedupe also added to upload command. * build: remove artifact cleanup action * feat(sync): add daisy-chain parameter * chore: module updates Co-authored-by: Eric Nemchik <[email protected]>
- Loading branch information
Showing
18 changed files
with
511 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,3 +42,4 @@ changelog: | |
exclude: | ||
- "^docs:" | ||
- "^test:" | ||
- "^Merge branch" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/dustin/go-humanize" | ||
"github.com/l3uddz/crop/config" | ||
"github.com/l3uddz/crop/uploader" | ||
"github.com/pkg/errors" | ||
"github.com/spf13/cobra" | ||
"strings" | ||
"time" | ||
) | ||
|
||
var dedupeCmd = &cobra.Command{ | ||
Use: "dedupe", | ||
Short: "Perform dedupe associated with uploader(s)", | ||
Long: `This command can be used to trigger a dedupe associated with uploader(s).`, | ||
|
||
Run: func(cmd *cobra.Command, args []string) { | ||
// init core | ||
initCore(true) | ||
defer releaseFileLock() | ||
|
||
// iterate uploader's | ||
started := time.Now().UTC() | ||
|
||
for _, uploaderConfig := range config.Config.Uploader { | ||
log := log.WithField("uploader", uploaderConfig.Name) | ||
|
||
// skip disabled uploader(s) | ||
if !uploaderConfig.Enabled { | ||
log.Debug("Skipping disabled uploader") | ||
continue | ||
} | ||
|
||
// skip uploader specific chosen | ||
if flagUploader != "" && !strings.EqualFold(uploaderConfig.Name, flagUploader) { | ||
log.Debugf("Skipping uploader as not: %q", flagUploader) | ||
continue | ||
} | ||
|
||
// create uploader | ||
upload, err := uploader.New(config.Config, &uploaderConfig, uploaderConfig.Name) | ||
if err != nil { | ||
log.WithError(err).Error("Failed initializing uploader, skipping...") | ||
continue | ||
} | ||
|
||
log.Info("Dedupe commencing...") | ||
|
||
// perform upload | ||
if err := performDedupe(upload); err != nil { | ||
upload.Log.WithError(err).Error("Error occurred while running dedupe, skipping...") | ||
continue | ||
} | ||
} | ||
|
||
log.Infof("Finished in: %v", humanize.RelTime(started, time.Now().UTC(), "", "")) | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(dedupeCmd) | ||
|
||
dedupeCmd.Flags().StringVarP(&flagUploader, "uploader", "u", "", "Run for a specific uploader") | ||
} | ||
|
||
func performDedupe(u *uploader.Uploader) error { | ||
u.Log.Info("Running dedupe...") | ||
|
||
/* Dedupe */ | ||
err := u.Dedupe(nil) | ||
if err != nil { | ||
return errors.Wrap(err, "failed dedupe remotes") | ||
} | ||
|
||
u.Log.Info("Finished dedupe!") | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.