cmd: added --retries-sleep flag

The --retries-sleep flag can be used to sleep after each retry.
This commit is contained in:
Benjamin Joseph Dag 2018-06-08 23:12:24 +08:00 committed by Nick Craig-Wood
parent 05edb5f501
commit da45dadfe9
2 changed files with 16 additions and 6 deletions

View File

@ -39,12 +39,13 @@ import (
// Globals
var (
// Flags
cpuProfile = flags.StringP("cpuprofile", "", "", "Write cpu profile to file")
memProfile = flags.StringP("memprofile", "", "", "Write memory profile to file")
statsInterval = flags.DurationP("stats", "", time.Minute*1, "Interval between printing stats, e.g 500ms, 60s, 5m. (0 to disable)")
dataRateUnit = flags.StringP("stats-unit", "", "bytes", "Show data rate in stats as either 'bits' or 'bytes'/s")
version bool
retries = flags.IntP("retries", "", 3, "Retry operations this many times if they fail")
cpuProfile = flags.StringP("cpuprofile", "", "", "Write cpu profile to file")
memProfile = flags.StringP("memprofile", "", "", "Write memory profile to file")
statsInterval = flags.DurationP("stats", "", time.Minute*1, "Interval between printing stats, e.g 500ms, 60s, 5m. (0 to disable)")
dataRateUnit = flags.StringP("stats-unit", "", "bytes", "Show data rate in stats as either 'bits' or 'bytes'/s")
version bool
retries = flags.IntP("retries", "", 3, "Retry operations this many times if they fail")
retriesInterval = flags.DurationP("retries-sleep", "", 0, "Interval between retrying operations if they fail, e.g 500ms, 60s, 5m. (0 to disable)")
// Errors
errorCommandNotFound = errors.New("command not found")
errorUncategorized = errors.New("uncategorized error")
@ -322,6 +323,9 @@ func Run(Retry bool, showStats bool, cmd *cobra.Command, f func() error) {
if try < *retries {
accounting.Stats.ResetErrors()
}
if *retriesInterval > 0 {
time.Sleep(*retriesInterval)
}
}
if showStats {
close(stopStats)

View File

@ -591,6 +591,12 @@ files which didn't get transferred because of errors.
Disable retries with `--retries 1`.
### --retries-sleep=TIME ###
This sets the interval between each retry specified by `--retries`
The default is 0. Use 0 to disable.
### --size-only ###
Normally rclone will look at modification time and size of files to