fs: calculate ModifyWindow each time on the fly instead of relying on global state - see #2319, #2328

This commit is contained in:
Stefan 2018-06-03 20:45:34 +02:00 committed by GitHub
parent 3ef938ebde
commit 4009fb67c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 43 additions and 83 deletions

View file

@ -306,7 +306,7 @@ func TestSyncIgnoreErrors(t *testing.T) {
"a",
"c",
},
fs.Config.ModifyWindow,
fs.GetModifyWindow(r.Fremote),
)
fstest.CheckListingWithPrecision(
t,
@ -320,7 +320,7 @@ func TestSyncIgnoreErrors(t *testing.T) {
"c",
"d",
},
fs.Config.ModifyWindow,
fs.GetModifyWindow(r.Fremote),
)
accounting.Stats.ResetCounters()
@ -338,7 +338,7 @@ func TestSyncIgnoreErrors(t *testing.T) {
"a",
"c",
},
fs.Config.ModifyWindow,
fs.GetModifyWindow(r.Fremote),
)
fstest.CheckListingWithPrecision(
t,
@ -351,7 +351,7 @@ func TestSyncIgnoreErrors(t *testing.T) {
"a",
"c",
},
fs.Config.ModifyWindow,
fs.GetModifyWindow(r.Fremote),
)
}
@ -413,11 +413,11 @@ func TestSyncAfterChangingModtimeOnlyWithNoUpdateModTime(t *testing.T) {
}
func TestSyncDoesntUpdateModtime(t *testing.T) {
if fs.Config.ModifyWindow == fs.ModTimeNotSupported {
t.Skip("Can't run this test on fs which doesn't support mod time")
}
r := fstest.NewRun(t)
defer r.Finalise()
if fs.GetModifyWindow(r.Fremote) == fs.ModTimeNotSupported {
t.Skip("Can't run this test on fs which doesn't support mod time")
}
file1 := r.WriteFile("foo", "foo", t2)
file2 := r.WriteObject("foo", "bar", t1)
@ -546,7 +546,7 @@ func TestSyncAfterRemovingAFileAndAddingAFileSubDir(t *testing.T) {
"a",
"c",
},
fs.Config.ModifyWindow,
fs.GetModifyWindow(r.Fremote),
)
fstest.CheckListingWithPrecision(
t,
@ -561,7 +561,7 @@ func TestSyncAfterRemovingAFileAndAddingAFileSubDir(t *testing.T) {
"d",
"d/e",
},
fs.Config.ModifyWindow,
fs.GetModifyWindow(r.Fremote),
)
accounting.Stats.ResetCounters()
@ -579,7 +579,7 @@ func TestSyncAfterRemovingAFileAndAddingAFileSubDir(t *testing.T) {
"a",
"c",
},
fs.Config.ModifyWindow,
fs.GetModifyWindow(r.Fremote),
)
fstest.CheckListingWithPrecision(
t,
@ -592,7 +592,7 @@ func TestSyncAfterRemovingAFileAndAddingAFileSubDir(t *testing.T) {
"a",
"c",
},
fs.Config.ModifyWindow,
fs.GetModifyWindow(r.Fremote),
)
}
@ -616,7 +616,7 @@ func TestSyncAfterRemovingAFileAndAddingAFileSubDirWithErrors(t *testing.T) {
"a",
"c",
},
fs.Config.ModifyWindow,
fs.GetModifyWindow(r.Fremote),
)
fstest.CheckListingWithPrecision(
t,
@ -630,7 +630,7 @@ func TestSyncAfterRemovingAFileAndAddingAFileSubDirWithErrors(t *testing.T) {
"c",
"d",
},
fs.Config.ModifyWindow,
fs.GetModifyWindow(r.Fremote),
)
accounting.Stats.ResetCounters()
@ -649,7 +649,7 @@ func TestSyncAfterRemovingAFileAndAddingAFileSubDirWithErrors(t *testing.T) {
"a",
"c",
},
fs.Config.ModifyWindow,
fs.GetModifyWindow(r.Fremote),
)
fstest.CheckListingWithPrecision(
t,
@ -665,7 +665,7 @@ func TestSyncAfterRemovingAFileAndAddingAFileSubDirWithErrors(t *testing.T) {
"c",
"d",
},
fs.Config.ModifyWindow,
fs.GetModifyWindow(r.Fremote),
)
}
@ -779,11 +779,11 @@ func TestSyncWithExcludeAndDeleteExcluded(t *testing.T) {
// Test with UpdateOlder set
func TestSyncWithUpdateOlder(t *testing.T) {
if fs.Config.ModifyWindow == fs.ModTimeNotSupported {
t.Skip("Can't run this test on fs which doesn't support mod time")
}
r := fstest.NewRun(t)
defer r.Finalise()
if fs.GetModifyWindow(r.Fremote) == fs.ModTimeNotSupported {
t.Skip("Can't run this test on fs which doesn't support mod time")
}
t2plus := t2.Add(time.Second / 2)
t2minus := t2.Add(time.Second / 2)
oneF := r.WriteFile("one", "one", t1)
@ -887,7 +887,7 @@ func testServerSideMove(t *testing.T, r *fstest.Run, withFilter, testDeleteEmpty
}
if testDeleteEmptyDirs {
fstest.CheckListingWithPrecision(t, r.Fremote, nil, []string{}, fs.Config.ModifyWindow)
fstest.CheckListingWithPrecision(t, r.Fremote, nil, []string{}, fs.GetModifyWindow(r.Fremote))
}
fstest.CheckItems(t, FremoteMove, file2, file1, file3u)
@ -916,7 +916,7 @@ func testServerSideMove(t *testing.T, r *fstest.Run, withFilter, testDeleteEmpty
}
if testDeleteEmptyDirs {
fstest.CheckListingWithPrecision(t, FremoteMove, nil, []string{}, fs.Config.ModifyWindow)
fstest.CheckListingWithPrecision(t, FremoteMove, nil, []string{}, fs.GetModifyWindow(r.Fremote))
}
}