forked from TrueCloudLab/rclone
sync: don't update mod times if --dry-run set - fixes #1100
This commit is contained in:
parent
f15c6b68b6
commit
b52c80e85c
2 changed files with 26 additions and 10 deletions
|
@ -172,6 +172,9 @@ func equal(src, dst Object, sizeOnly, checkSum bool) bool {
|
||||||
|
|
||||||
// mod time differs but hash is the same to reset mod time if required
|
// mod time differs but hash is the same to reset mod time if required
|
||||||
if !Config.NoUpdateModTime {
|
if !Config.NoUpdateModTime {
|
||||||
|
if Config.DryRun {
|
||||||
|
Logf(src, "Not updating modification time as --dry-run")
|
||||||
|
} else {
|
||||||
// Size and hash the same but mtime different so update the
|
// Size and hash the same but mtime different so update the
|
||||||
// mtime of the dst object here
|
// mtime of the dst object here
|
||||||
err := dst.SetModTime(srcModTime)
|
err := dst.SetModTime(srcModTime)
|
||||||
|
@ -185,6 +188,7 @@ func equal(src, dst Object, sizeOnly, checkSum bool) bool {
|
||||||
Infof(src, "Updated modification time in destination")
|
Infof(src, "Updated modification time in destination")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -308,10 +308,22 @@ func TestSyncAfterChangingModtimeOnly(t *testing.T) {
|
||||||
fstest.CheckItems(t, r.flocal, file1)
|
fstest.CheckItems(t, r.flocal, file1)
|
||||||
fstest.CheckItems(t, r.fremote, file2)
|
fstest.CheckItems(t, r.fremote, file2)
|
||||||
|
|
||||||
|
fs.Config.DryRun = true
|
||||||
|
defer func() { fs.Config.DryRun = false }()
|
||||||
|
|
||||||
fs.Stats.ResetCounters()
|
fs.Stats.ResetCounters()
|
||||||
err := fs.Sync(r.fremote, r.flocal)
|
err := fs.Sync(r.fremote, r.flocal)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
fstest.CheckItems(t, r.flocal, file1)
|
||||||
|
fstest.CheckItems(t, r.fremote, file2)
|
||||||
|
|
||||||
|
fs.Config.DryRun = false
|
||||||
|
|
||||||
|
fs.Stats.ResetCounters()
|
||||||
|
err = fs.Sync(r.fremote, r.flocal)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
fstest.CheckItems(t, r.flocal, file1)
|
fstest.CheckItems(t, r.flocal, file1)
|
||||||
fstest.CheckItems(t, r.fremote, file1)
|
fstest.CheckItems(t, r.fremote, file1)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue