sync: implement directory sync for mod times and metadata

Directory mod times are synced by default if the backend is capable
and directory metadata is synced if the --metadata flag is provided
and the backend is capable.

This updates the bisync golden tests also which were affected by
--dry-run setting of directory modtimes.

Fixes #6685
This commit is contained in:
Nick Craig-Wood
2024-02-06 16:00:34 +00:00
parent 15579c2195
commit f5f86786b2
23 changed files with 504 additions and 14 deletions

View File

@@ -360,6 +360,22 @@ func (r *Run) CheckRemoteListing(t *testing.T, items []Item, expectedDirs []stri
CheckListingWithPrecision(t, r.Fremote, items, expectedDirs, r.Precision)
}
// CheckDirectoryModTimes checks that the directory names in r.Flocal has the correct modtime compared to r.Fremote
func (r *Run) CheckDirectoryModTimes(t *testing.T, names ...string) {
if r.Fremote.Features().DirSetModTime == nil && r.Fremote.Features().MkdirMetadata == nil {
fs.Debugf(r.Fremote, "Skipping modtime test as remote does not support DirSetModTime or MkdirMetadata")
return
}
ctx := context.Background()
for _, name := range names {
wantT := NewDirectory(ctx, t, r.Flocal, name).ModTime(ctx)
got := NewDirectory(ctx, t, r.Fremote, name)
gotT := got.ModTime(ctx)
fs.Debugf(r.Fremote, "Testing directory mod time of %q: wantT=%v, gotT=%v", name, wantT, gotT)
AssertTimeEqualWithPrecision(t, got.Remote(), wantT, gotT, fs.GetModifyWindow(ctx, r.Fremote, r.Flocal))
}
}
// Clean the temporary directory
func (r *Run) cleanTempDir() {
err := os.RemoveAll(r.LocalName)