operations: Made copy and sync operations obey a RetryAfterError

This commit is contained in:
Ankur Gupta 2021-02-10 23:29:10 +05:30 committed by Nick Craig-Wood
parent c0c2505977
commit 47b69d6300
1 changed files with 9 additions and 0 deletions

View File

@ -32,6 +32,7 @@ import (
"github.com/rclone/rclone/fs/object"
"github.com/rclone/rclone/fs/walk"
"github.com/rclone/rclone/lib/atexit"
"github.com/rclone/rclone/lib/pacer"
"github.com/rclone/rclone/lib/random"
"github.com/rclone/rclone/lib/readers"
"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
}
// Retry if err returned a retry error
var retry bool
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)
tr.Reset(ctx) // skip incomplete accounting - will be overwritten by retry
continue