sync: Fix --max-duration so it doesn't retry when the duration is exceeded

Before this change, if the --max-duration limit was reached then
rclone would retry the sync as a fatal error wasn't raised.

This checks the deadline and raises a fatal error if necessary at the
end of the sync.

Fixes #6002
This commit is contained in:
Nick Craig-Wood 2022-02-24 10:03:41 +00:00
parent 251b84ff2c
commit 21355b4208
2 changed files with 15 additions and 4 deletions

View file

@ -1029,7 +1029,7 @@ func TestSyncWithMaxDuration(t *testing.T) {
accounting.GlobalStats().ResetCounters()
startTime := time.Now()
err := Sync(ctx, r.Fremote, r.Flocal, false)
require.True(t, errors.Is(err, context.DeadlineExceeded))
require.True(t, errors.Is(err, errorMaxDurationReached))
elapsed := time.Since(startTime)
maxTransferTime := (time.Duration(len(testFiles)) * 60 * time.Second) / time.Duration(bytesPerSecond)