From 0c6f14c69437ea614e7441455ae120bf8f2ffaa9 Mon Sep 17 00:00:00 2001 From: Ishuah Kariuki Date: Tue, 3 Mar 2020 19:24:22 +0300 Subject: [PATCH] copy/sync: only create empty directories when they don't exist on the remote Sync/copy now only creates empty directories when they don't exist on the remote (--create-empty-src-dirs flag) - fixes #2800 --- fs/sync/sync.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/fs/sync/sync.go b/fs/sync/sync.go index fbae10f9a..c3887c9e6 100644 --- a/fs/sync/sync.go +++ b/fs/sync/sync.go @@ -879,11 +879,15 @@ func (s *syncCopyMove) Match(ctx context.Context, dst, src fs.DirEntry) (recurse // Do the same thing to the entire contents of the directory _, ok := dst.(fs.Directory) if ok { - // Record the src directory for deletion - s.srcEmptyDirsMu.Lock() - s.srcParentDirCheck(src) - s.srcEmptyDirs[src.Remote()] = src - s.srcEmptyDirsMu.Unlock() + // Only record matched (src & dst) empty dirs when performing move + if s.DoMove { + // Record the src directory for deletion + s.srcEmptyDirsMu.Lock() + s.srcParentDirCheck(src) + s.srcEmptyDirs[src.Remote()] = src + s.srcEmptyDirsMu.Unlock() + } + return true } // FIXME src is dir, dst is file