vfs: Add a missed update of used cache space

The missed update can cause incorrect before-cleaning cache stats
and a pre-mature condition broadcast in purgeOld before the cache
space use is reduced below the quota.
This commit is contained in:
Leo Luan 2020-10-05 02:00:00 -07:00 committed by Nick Craig-Wood
parent 2295123cad
commit c5c56cda02

View File

@ -610,6 +610,7 @@ func (c *Cache) clean(removeCleanFiles bool) {
if os.IsNotExist(err) { if os.IsNotExist(err) {
return return
} }
c.updateUsed()
c.mu.Lock() c.mu.Lock()
oldItems, oldUsed := len(c.item), fs.SizeSuffix(c.used) oldItems, oldUsed := len(c.item), fs.SizeSuffix(c.used)
c.mu.Unlock() c.mu.Unlock()