diff --git a/bin/test-repeat-vfs.sh b/bin/test-repeat-vfs.sh index c0eee3795..c9702a870 100755 --- a/bin/test-repeat-vfs.sh +++ b/bin/test-repeat-vfs.sh @@ -3,6 +3,9 @@ set -e +# Optionally set the iterations with the first parameter +iterations=${1:-100} + base=$(dirname $(dirname $(realpath "$0"))) echo ${base} run=${base}/bin/test-repeat.sh @@ -17,7 +20,7 @@ cmd/cmount " for testdir in ${testdirs}; do - echo "Testing ${testdir}" + echo "Testing ${testdir} with ${iterations} iterations" cd ${base}/${testdir} - ${run} -c=100 -race -tags=cmount + ${run} -i=${iterations} -race -tags=cmount done diff --git a/vfs/file.go b/vfs/file.go index db2bc8a27..eb1103cd3 100644 --- a/vfs/file.go +++ b/vfs/file.go @@ -351,6 +351,11 @@ func (f *File) SetModTime(modTime time.Time) error { f.pendingModTime = modTime + // set the time of the file in the cache + if f.d.vfs.cache != nil && f.d.vfs.cache.Exists(f._path()) { + f.d.vfs.cache.SetModTime(f._path(), f.pendingModTime) + } + // Only update the ModTime when there are no writers, setObject will do it if !f._writingInProgress() { return f._applyPendingModTime() @@ -384,11 +389,6 @@ func (f *File) _applyPendingModTime() error { return err } - // set the time of the file in the cache - if f.d.vfs.cache != nil && f.d.vfs.cache.Exists(f._path()) { - f.d.vfs.cache.SetModTime(f._path(), f.pendingModTime) - } - return nil } diff --git a/vfs/vfscache/item.go b/vfs/vfscache/item.go index 835151ef6..17317a34a 100644 --- a/vfs/vfscache/item.go +++ b/vfs/vfscache/item.go @@ -877,6 +877,7 @@ func (item *Item) setModTime(modTime time.Time) { item.mu.Lock() item._updateFingerprint() item._setModTime(modTime) + item.info.ModTime = modTime err := item._save() if err != nil { fs.Errorf(item.name, "vfs cache: setModTime: failed to save item info: %v", err)