forked from TrueCloudLab/rclone
lib/cache: fix alias backend shutting down too soon
Before this patch, when an alias backend was created it would be renamed to be canonical and in the process Shutdown would be called on it. This was particularly noticeable with the dropbox backend which gave this error when uploading files after the backend was Shutdown. Failed to copy: upload failed: batcher is shutting down This patch fixes the cache Rename code not to finalize objects if the object that is being overwritten is the same as the existing object. See: https://forum.rclone.org/t/upload-failed-batcher-is-shutting-down/33900
This commit is contained in:
parent
3a3bc5a1ae
commit
919e28b8bf
1 changed files with 5 additions and 3 deletions
6
lib/cache/cache.go
vendored
6
lib/cache/cache.go
vendored
|
@ -190,10 +190,12 @@ func (c *Cache) Rename(oldKey, newKey string) (value interface{}, found bool) {
|
|||
c.mu.Lock()
|
||||
if newEntry, newFound := c.cache[newKey]; newFound {
|
||||
// If new entry is found use that
|
||||
if _, oldFound := c.cache[oldKey]; oldFound {
|
||||
// If there's an old entry, we drop it and also try shutdown.
|
||||
if oldEntry, oldFound := c.cache[oldKey]; oldFound {
|
||||
// If there's an old entry that is different we must finalize it
|
||||
if newEntry.value != oldEntry.value {
|
||||
c.finalize(c.cache[oldKey].value)
|
||||
}
|
||||
}
|
||||
delete(c.cache, oldKey)
|
||||
value, found = newEntry.value, newFound
|
||||
c.used(newEntry)
|
||||
|
|
Loading…
Reference in a new issue