From 1ab49850468a00b7e3131f985f36d90831091fe4 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Mon, 9 Dec 2019 15:23:08 +0000 Subject: [PATCH] vfs: when renaming files in the cache, rename the cache item in memory too --- vfs/cache.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/vfs/cache.go b/vfs/cache.go index 41ace3005..8a9ade07a 100644 --- a/vfs/cache.go +++ b/vfs/cache.go @@ -309,6 +309,13 @@ func (c *cache) rename(name string, newName string) (err error) { if err = os.Rename(osOldPath, osNewPath); err != nil { return errors.Wrapf(err, "Failed to rename in cache: %s to %s", osOldPath, osNewPath) } + // Rename the cache item + c.itemMu.Lock() + if oldItem, ok := c.item[name]; ok { + c.item[newName] = oldItem + delete(c.item, name) + } + c.itemMu.Unlock() fs.Infof(name, "Renamed in cache") return nil }