fs/operations: Don't update timestamps of files in --compare-dest

This commit is contained in:
Nick Gaya 2021-06-14 13:19:12 -07:00 committed by Nick Craig-Wood
parent 04aa6969a4
commit 40024990b7
2 changed files with 19 additions and 7 deletions

View File

@ -1408,7 +1408,9 @@ func compareDest(ctx context.Context, dst, src fs.Object, CompareDest fs.Fs) (No
default:
return false, err
}
if Equal(ctx, src, CompareDestFile) {
opt := defaultEqualOpt(ctx)
opt.updateModTime = false
if equal(ctx, src, CompareDestFile, opt) {
fs.Debugf(src, "Destination found in --compare-dest, skipping")
return true, nil
}

View File

@ -1496,19 +1496,29 @@ func TestSyncCompareDest(t *testing.T) {
fstest.CheckItems(t, r.Fremote, file2, file3, file4)
// check empty dest, old compare
file5b := r.WriteFile("two", "twot3", t3)
fstest.CheckItems(t, r.Fremote, file2, file3, file4)
// check new dest, new compare, src timestamp differs
file5b := r.WriteFile("two", "two", t3)
fstest.CheckItems(t, r.Flocal, file1c, file5b)
accounting.GlobalStats().ResetCounters()
err = Sync(ctx, fdst, r.Flocal, false)
require.NoError(t, err)
file5bdst := file5b
file5bdst.Path = "dst/two"
fstest.CheckItems(t, r.Fremote, file2, file3, file4)
fstest.CheckItems(t, r.Fremote, file2, file3, file4, file5bdst)
// check empty dest, old compare
file5c := r.WriteFile("two", "twot3", t3)
fstest.CheckItems(t, r.Fremote, file2, file3, file4)
fstest.CheckItems(t, r.Flocal, file1c, file5c)
accounting.GlobalStats().ResetCounters()
err = Sync(ctx, fdst, r.Flocal, false)
require.NoError(t, err)
file5cdst := file5c
file5cdst.Path = "dst/two"
fstest.CheckItems(t, r.Fremote, file2, file3, file4, file5cdst)
}
// Test with multiple CompareDest