From 9b43836e19d06b9a5d3c71eca9f67001d0fbdc8c Mon Sep 17 00:00:00 2001 From: nielash Date: Tue, 24 Jun 2025 21:48:53 -0400 Subject: [PATCH] sync: avoid copying dir metadata to itself In convmv, src and dst can point to the same directory. Unless a dir's name is changing, we should leave it alone and not attempt to copy its metadata to itself. --- fs/sync/sync.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/sync/sync.go b/fs/sync/sync.go index c7593f673..d40f2cfaf 100644 --- a/fs/sync/sync.go +++ b/fs/sync/sync.go @@ -1109,6 +1109,9 @@ func (s *syncCopyMove) markDirModifiedObject(o fs.Object) { // be nil. func (s *syncCopyMove) copyDirMetadata(ctx context.Context, f fs.Fs, dst fs.Directory, dir string, src fs.Directory) (newDst fs.Directory) { var err error + if dst != nil && src.Remote() == dst.Remote() && operations.OverlappingFilterCheck(ctx, s.fdst, s.fsrc) { + return nil // src and dst can be the same in convmv + } equal := operations.DirsEqual(ctx, src, dst, operations.DirsEqualOpt{ModifyWindow: s.modifyWindow, SetDirModtime: s.setDirModTime, SetDirMetadata: s.setDirMetadata}) if !s.setDirModTimeAfter && equal { return nil