From 563c4f76c66675e6dec19a2834878336a9313966 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Tue, 6 Apr 2021 12:59:36 +0100 Subject: [PATCH] sync: fix incorrect error reported by graceful cutoff - fixes #5203 Before this change, a sync which was finished with a graceful transfer cutoff could return "context canceled" instead of the correct error. This fixes the problem by ignoring "context canceled" errors if we have done a graceful stop. --- fs/sync/sync.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/sync/sync.go b/fs/sync/sync.go index e8ce10ad1..0a6cfdfb7 100644 --- a/fs/sync/sync.go +++ b/fs/sync/sync.go @@ -264,6 +264,9 @@ func (s *syncCopyMove) processError(err error) { // Cancel the march and stop the pipes s.inCancel() } + } else if err == context.Canceled && s.inCtx.Err() != nil { + // Ignore context Canceled if we have called s.inCancel() + return } s.errorMu.Lock() defer s.errorMu.Unlock()