Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

lib/cache: fix alias backend shutting down too soon

Nick Craig-Wood919e28b8bf1b
diff --git a/lib/cache/cache.go b/lib/cache/cache.go
index 8e03819bc..cbcf78796 100644
--- a/lib/cache/cache.go
+++ b/lib/cache/cache.go
@@ -190,9 +190,11 @@ 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.
- c.finalize(c.cache[oldKey].value)
+ 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