forked from TrueCloudLab/rclone
vfs: when renaming files in the cache, rename the cache item in memory too
This commit is contained in:
parent
6e683b4359
commit
1ab4985046
1 changed files with 7 additions and 0 deletions
|
@ -309,6 +309,13 @@ func (c *cache) rename(name string, newName string) (err error) {
|
||||||
if err = os.Rename(osOldPath, osNewPath); err != nil {
|
if err = os.Rename(osOldPath, osNewPath); err != nil {
|
||||||
return errors.Wrapf(err, "Failed to rename in cache: %s to %s", osOldPath, osNewPath)
|
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")
|
fs.Infof(name, "Renamed in cache")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue