diff --git a/vfs/file.go b/vfs/file.go index 44a4ebb88..52fff453e 100644 --- a/vfs/file.go +++ b/vfs/file.go @@ -322,7 +322,9 @@ func (f *File) ModTime() (modTime time.Time) { } // Read the modtime from a dirty item if it exists if f.d.vfs.Opt.CacheMode >= vfscommon.CacheModeMinimal { - if item := f.d.vfs.cache.DirtyItem(f._path()); item != nil { + item := f.d.vfs.cache.ItemOrNil(f._path()) + noModTime := f.d.f.Precision() == fs.ModTimeNotSupported + if item != nil && (item.IsDirty() || noModTime) { modTime, err := item.GetModTime() if err != nil { fs.Errorf(f._path(), "ModTime: Item GetModTime failed: %v", err) diff --git a/vfs/vfscache/item.go b/vfs/vfscache/item.go index e1575eca3..431599b63 100644 --- a/vfs/vfscache/item.go +++ b/vfs/vfscache/item.go @@ -1223,7 +1223,7 @@ func (item *Item) setModTime(modTime time.Time) { item.mu.Unlock() } -// GetModTime of the cache file +// GetModTime of the cache item func (item *Item) GetModTime() (modTime time.Time, err error) { // defer log.Trace(item.name, "modTime=%v", modTime)("") item.mu.Lock() @@ -1231,6 +1231,9 @@ func (item *Item) GetModTime() (modTime time.Time, err error) { fi, err := item._stat() if err == nil { modTime = fi.ModTime() + item.info.ModTime = modTime + } else { + modTime = item.info.ModTime } return modTime, nil }