fs/operations: Don't update timestamps of files in --compare-dest
This commit is contained in:
parent
04aa6969a4
commit
40024990b7
2 changed files with 19 additions and 7 deletions
|
@ -1408,7 +1408,9 @@ func compareDest(ctx context.Context, dst, src fs.Object, CompareDest fs.Fs) (No
|
||||||
default:
|
default:
|
||||||
return false, err
|
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")
|
fs.Debugf(src, "Destination found in --compare-dest, skipping")
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1496,19 +1496,29 @@ func TestSyncCompareDest(t *testing.T) {
|
||||||
|
|
||||||
fstest.CheckItems(t, r.Fremote, file2, file3, file4)
|
fstest.CheckItems(t, r.Fremote, file2, file3, file4)
|
||||||
|
|
||||||
// check empty dest, old compare
|
// check new dest, new compare, src timestamp differs
|
||||||
file5b := r.WriteFile("two", "twot3", t3)
|
file5b := r.WriteFile("two", "two", t3)
|
||||||
fstest.CheckItems(t, r.Fremote, file2, file3, file4)
|
|
||||||
fstest.CheckItems(t, r.Flocal, file1c, file5b)
|
fstest.CheckItems(t, r.Flocal, file1c, file5b)
|
||||||
|
|
||||||
accounting.GlobalStats().ResetCounters()
|
accounting.GlobalStats().ResetCounters()
|
||||||
err = Sync(ctx, fdst, r.Flocal, false)
|
err = Sync(ctx, fdst, r.Flocal, false)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
file5bdst := file5b
|
fstest.CheckItems(t, r.Fremote, file2, file3, file4)
|
||||||
file5bdst.Path = "dst/two"
|
|
||||||
|
|
||||||
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
|
// Test with multiple CompareDest
|
||||||
|
|
Loading…
Reference in a new issue