From 40024990b73ac4d834505efb7f801f66178ab262 Mon Sep 17 00:00:00 2001 From: Nick Gaya Date: Mon, 14 Jun 2021 13:19:12 -0700 Subject: [PATCH] fs/operations: Don't update timestamps of files in --compare-dest --- fs/operations/operations.go | 4 +++- fs/sync/sync_test.go | 22 ++++++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/fs/operations/operations.go b/fs/operations/operations.go index 0547ab9ab..c3c353aff 100644 --- a/fs/operations/operations.go +++ b/fs/operations/operations.go @@ -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 } diff --git a/fs/sync/sync_test.go b/fs/sync/sync_test.go index 6a8caec5f..a2d2933bb 100644 --- a/fs/sync/sync_test.go +++ b/fs/sync/sync_test.go @@ -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