mirror of https://github.com/rclone/rclone.git
sync: copy dir modtimes even when copyEmptySrcDirs is false - fixes #8317
Before, after a sync, only file modtimes were updated when not using --copy-empty-src-dirs. This ensures modtimes are updated to match the source folder, regardless of copyEmptySrcDir. The flag --no-update-dir-modtime (which previously did nothing) will disable this.
This commit is contained in:
parent
2ff8aa1c20
commit
c1b414e2cf
|
@ -1109,23 +1109,17 @@ func (s *syncCopyMove) copyDirMetadata(ctx context.Context, f fs.Fs, dst fs.Dire
|
||||||
if !s.setDirModTimeAfter && equal {
|
if !s.setDirModTimeAfter && equal {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if s.setDirModTimeAfter && equal {
|
newDst = dst
|
||||||
newDst = dst
|
if !equal {
|
||||||
} else if s.copyEmptySrcDirs {
|
if s.setDirMetadata && s.copyEmptySrcDirs {
|
||||||
if s.setDirMetadata {
|
|
||||||
newDst, err = operations.CopyDirMetadata(ctx, f, dst, dir, src)
|
newDst, err = operations.CopyDirMetadata(ctx, f, dst, dir, src)
|
||||||
} else if s.setDirModTime {
|
} else if dst == nil && s.setDirModTime && s.copyEmptySrcDirs {
|
||||||
if dst == nil {
|
newDst, err = operations.MkdirModTime(ctx, f, dir, src.ModTime(ctx))
|
||||||
newDst, err = operations.MkdirModTime(ctx, f, dir, src.ModTime(ctx))
|
} else if dst == nil && s.copyEmptySrcDirs {
|
||||||
} else {
|
|
||||||
newDst, err = operations.SetDirModTime(ctx, f, dst, dir, src.ModTime(ctx))
|
|
||||||
}
|
|
||||||
} else if dst == nil {
|
|
||||||
// Create the directory if it doesn't exist
|
|
||||||
err = operations.Mkdir(ctx, f, dir)
|
err = operations.Mkdir(ctx, f, dir)
|
||||||
|
} else if dst != nil && s.setDirModTime {
|
||||||
|
newDst, err = operations.SetDirModTime(ctx, f, dst, dir, src.ModTime(ctx))
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
newDst = dst
|
|
||||||
}
|
}
|
||||||
// If we need to set modtime after and we created a dir, then save it for later
|
// If we need to set modtime after and we created a dir, then save it for later
|
||||||
if s.setDirModTime && s.setDirModTimeAfter && err == nil {
|
if s.setDirModTime && s.setDirModTimeAfter && err == nil {
|
||||||
|
|
Loading…
Reference in New Issue