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.
This commit is contained in:
huanghaojun 2025-04-09 18:58:09 +08:00 committed by GitHub
parent a5d03e0ada
commit 49f6ed5f5e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -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