Skip to content

Commit 1ab4985

Browse files
committed
vfs: when renaming files in the cache, rename the cache item in memory too
1 parent 6e683b4 commit 1ab4985

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

vfs/cache.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,13 @@ func (c *cache) rename(name string, newName string) (err error) {
309309
if err = os.Rename(osOldPath, osNewPath); err != nil {
310310
return errors.Wrapf(err, "Failed to rename in cache: %s to %s", osOldPath, osNewPath)
311311
}
312+
// Rename the cache item
313+
c.itemMu.Lock()
314+
if oldItem, ok := c.item[name]; ok {
315+
c.item[newName] = oldItem
316+
delete(c.item, name)
317+
}
318+
c.itemMu.Unlock()
312319
fs.Infof(name, "Renamed in cache")
313320
return nil
314321
}

0 commit comments

Comments
 (0)