From 49f6ed5f5e41deab9571cee856739b7422924224 Mon Sep 17 00:00:00 2001 From: huanghaojun Date: Wed, 9 Apr 2025 18:58:09 +0800 Subject: [PATCH] vfs: fix inefficient directory caching when directory reads are slow Before this change, when querying directories with large datasets, if the query duration exceeded the directory cache expiration time, the cache became invalid by the time results were retrieved. This means every execution of `_readDir` triggers `_readDirFromEntries`, resulting in prolonged processing times. After this change we update the directory time with the time at the end of the query. --- vfs/dir.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vfs/dir.go b/vfs/dir.go index 12d9591a0..174b7d001 100644 --- a/vfs/dir.go +++ b/vfs/dir.go @@ -581,7 +581,7 @@ func (d *Dir) _readDir() error { return err } - d.read = when + d.read = time.Now() d.cleanupTimer.Reset(time.Duration(d.vfs.Opt.DirCacheTime * 2)) return nil