MCPcopy
hub / github.com/rclone/rclone / TestDirEntryModTimeInvalidation

Function TestDirEntryModTimeInvalidation

vfs/dir_test.go:662–696  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

660}
661
662func TestDirEntryModTimeInvalidation(t *testing.T) {
663 r, vfs := newTestVFS(t)
664 features := r.Fremote.Features()
665 if !features.DirModTimeUpdatesOnWrite {
666 t.Skip("Need DirModTimeUpdatesOnWrite")
667 }
668 if features.IsLocal && runtime.GOOS == "windows" {
669 t.Skip("dirent modtime is unreliable on Windows filesystems")
670 }
671
672 r.WriteObject(context.Background(), "dir/file1", "file1 contents", t1)
673
674 // Read the modtime of the directory fresh
675 vfs.FlushDirCache()
676 node, err := vfs.Stat("dir")
677 require.NoError(t, err)
678 modTime1 := node.(*Dir).DirEntry().ModTime(context.Background())
679
680 // Wait some time (we wait for Precision+10%), then write another file
681 // which should update the ModTime of the directory.
682 prec := (11 * vfs.f.Precision()) / 10
683 time.Sleep(max(100*time.Millisecond, prec))
684 r.WriteObject(context.Background(), "dir/file2", "file2 contents", t2)
685
686 // Read the modtime of the directory fresh again - it should have changed
687 vfs.FlushDirCache()
688 node2, err := vfs.Stat("dir")
689 require.NoError(t, err)
690 modTime2 := node2.(*Dir).DirEntry().ModTime(context.Background())
691
692 // ModTime of directory must be different after second file was written.
693 if modTime1.Equal(modTime2) {
694 t.Error("ModTime not invalidated")
695 }
696}
697
698func TestDirMetadataExtension(t *testing.T) {
699 r, vfs, dir, _ := dirCreate(t)

Callers

nothing calls this directly

Calls 10

newTestVFSFunction · 0.85
WriteObjectMethod · 0.80
FlushDirCacheMethod · 0.80
FeaturesMethod · 0.65
StatMethod · 0.65
ModTimeMethod · 0.65
DirEntryMethod · 0.65
PrecisionMethod · 0.65
ErrorMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…