Skip to content

Commit

Permalink
sync: fix marking of directories as modified to mark the parent direc…
Browse files Browse the repository at this point in the history
…tory
  • Loading branch information
ncw committed Apr 6, 2024
1 parent 92a9c51 commit dd463b2
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions fs/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -1086,10 +1086,16 @@ func (s *syncCopyMove) DstOnly(dst fs.DirEntry) (recurse bool) {
}

// keeps track of dirs with changed contents, to avoid setting modtimes on dirs that haven't changed
func (s *syncCopyMove) markDirModified(dir string) {
//
// marks the parent of entry as modified
func (s *syncCopyMove) markDirModified(entry string) {
if !s.setDirModTimeAfter {
return
}
dir := path.Dir(entry)

This comment has been minimized.

Copy link
@nielash

nielash Apr 6, 2024

Collaborator

@ncw I'm confused about this change. Won't it cause the following to be wrong? (x is a dir here, not an object)

s.markDirModified(x.Remote())

if dir == "." {
dir = ""
}
s.setDirModTimeMu.Lock()
defer s.setDirModTimeMu.Unlock()
s.modifiedDirs[dir] = struct{}{}
Expand All @@ -1098,11 +1104,7 @@ func (s *syncCopyMove) markDirModified(dir string) {
// like markDirModified, but accepts an Object instead of a string.
// the marked dir will be this object's parent.
func (s *syncCopyMove) markDirModifiedObject(o fs.Object) {
dir := path.Dir(o.Remote())
if dir == "." {
dir = ""
}
s.markDirModified(dir)
s.markDirModified(o.Remote())
}

// copyDirMetadata copies the src directory modTime or Metadata to dst
Expand Down

0 comments on commit dd463b2

Please sign in to comment.