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

vfs: Fix race condition in vfscache

Nick Craig-Wood530dc77cdefd
diff --git a/vfs/vfscache/item.go b/vfs/vfscache/item.go
index 9d27d57c8..ca759ba67 100644
--- a/vfs/vfscache/item.go
+++ b/vfs/vfscache/item.go
@@ -488,8 +488,9 @@ func (item *Item) _store(ctx context.Context, storeFn StoreFn) (err error) {
// Object has disappeared if cacheObj == nil
if cacheObj != nil {
+ o, name := item.o, item.name
item.mu.Unlock()
- o, err := operations.Copy(ctx, item.c.fremote, item.o, item.name, cacheObj)
+ o, err := operations.Copy(ctx, item.c.fremote, o, name, cacheObj)
item.mu.Lock()
if err != nil {
return errors.Wrap(err, "vfs cache: failed to transfer file from cache to remote")