Skip to content

Commit

Permalink
copy/sync: only create empty directories when they don't exist on the…
Browse files Browse the repository at this point in the history
… remote

Sync/copy now only creates empty directories when they don't exist on the remote (--create-empty-src-dirs flag) - fixes #2800
  • Loading branch information
ishuah committed Mar 3, 2020
1 parent 1c800ef commit 0c6f14c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions fs/sync/sync.go
Expand Up @@ -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
Expand Down

0 comments on commit 0c6f14c

Please sign in to comment.