From 23ab6fa3a0ca7516b76f98e564f076242a9839d8 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Mon, 30 Oct 2023 16:45:20 +0000 Subject: [PATCH] operations: fix server side copies on partial upload backends after refactor After the copy refactor: 179f978f75ed9742 operations: refactor Copy into methods on an temporary object There was some confusion in the code about server side copies - should they or shouldn't they use partials? This manifested in unit test failures for remotes which supported server side Copy and PartialUploads. This combination is rare and only exists in the sftp backend with the --sftp-copy-is-hardlink flag. This fix makes the choice that backends which set PartialUploads always use partials even for server side copies. --- fs/operations/copy.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/fs/operations/copy.go b/fs/operations/copy.go index a2a2ebebd..596c7ed04 100644 --- a/fs/operations/copy.go +++ b/fs/operations/copy.go @@ -146,11 +146,8 @@ func (c *copy) serverSideCopy(ctx context.Context) (actionTaken string, newDst f newDst, err = doCopy(ctx, c.src, c.remoteForCopy) if err == nil { in.ServerSideCopyEnd(newDst.Size()) // account the bytes for the server-side transfer - _ = in.Close() - c.inplace = true - } else { - _ = in.Close() } + _ = in.Close() if errors.Is(err, fs.ErrorCantCopy) { c.tr.Reset(ctx) // skip incomplete accounting - will be overwritten by the manual copy }