Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

copy/sync: only create empty directories when they don't exist on the remote

Ishuah Kariuki0c6f14c69437
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