operations: Made copy and sync operations obey a RetryAfterError
This commit is contained in:
parent
c0c2505977
commit
47b69d6300
1 changed files with 9 additions and 0 deletions
|
@ -32,6 +32,7 @@ import (
|
||||||
"github.com/rclone/rclone/fs/object"
|
"github.com/rclone/rclone/fs/object"
|
||||||
"github.com/rclone/rclone/fs/walk"
|
"github.com/rclone/rclone/fs/walk"
|
||||||
"github.com/rclone/rclone/lib/atexit"
|
"github.com/rclone/rclone/lib/atexit"
|
||||||
|
"github.com/rclone/rclone/lib/pacer"
|
||||||
"github.com/rclone/rclone/lib/random"
|
"github.com/rclone/rclone/lib/random"
|
||||||
"github.com/rclone/rclone/lib/readers"
|
"github.com/rclone/rclone/lib/readers"
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
|
@ -483,7 +484,15 @@ func Copy(ctx context.Context, f fs.Fs, dst fs.Object, remote string, src fs.Obj
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
// Retry if err returned a retry error
|
// Retry if err returned a retry error
|
||||||
|
var retry bool
|
||||||
if fserrors.IsRetryError(err) || fserrors.ShouldRetry(err) {
|
if fserrors.IsRetryError(err) || fserrors.ShouldRetry(err) {
|
||||||
|
retry = true
|
||||||
|
} else if t, ok := pacer.IsRetryAfter(err); ok {
|
||||||
|
fs.Debugf(src, "Sleeping for %v (as indicated by the server) to obey Retry-After error: %v", t, err)
|
||||||
|
time.Sleep(t)
|
||||||
|
retry = true
|
||||||
|
}
|
||||||
|
if retry {
|
||||||
fs.Debugf(src, "Received error: %v - low level retry %d/%d", err, tries, maxTries)
|
fs.Debugf(src, "Received error: %v - low level retry %d/%d", err, tries, maxTries)
|
||||||
tr.Reset(ctx) // skip incomplete accounting - will be overwritten by retry
|
tr.Reset(ctx) // skip incomplete accounting - will be overwritten by retry
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in a new issue