"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
vfs: vfscache: Fix renaming of items while they are being uploaded
Nick Craig-Woodc65ed26a7ecb
diff --git a/vfs/vfscache/item.go b/vfs/vfscache/item.goindex 796719eec..b7dbec428 100644--- a/vfs/vfscache/item.go+++ b/vfs/vfscache/item.go@@ -1018,36 +1018,35 @@ func (item *Item) Sync() (err error) {// rename the itemfunc (item *Item) rename(name string, newName string, newObj fs.Object) (err error) {- var downloaders *downloaders.Downloaders- // close downloader with mutex unlocked- defer func() {- if downloaders != nil {- _ = downloaders.Close(nil)- }- }()-item.mu.Lock()- defer item.mu.Unlock()// stop downloader- downloaders = item.downloaders+ downloaders := item.downloadersitem.downloaders = nil+ // id for writeback cancel+ id := item.writeBackID+// Set internal stateitem.name = newNameitem.o = newObj// Rename cache file if it existserr = rename(item.c.toOSPath(name), item.c.toOSPath(newName)) // No locking in Cache- if err != nil {- return err- }// Rename meta file if it exists- err = rename(item.c.toOSPathMeta(name), item.c.toOSPathMeta(newName)) // No locking in Cache- if err != nil {- return err+ err2 := rename(item.c.toOSPathMeta(name), item.c.toOSPathMeta(newName)) // No locking in Cache+ if err2 != nil {+ err = err2}- return nil+ item.mu.Unlock()++ // close downloader and cancel writebacks with mutex unlocked+ if downloaders != nil {+ _ = downloaders.Close(nil)+ }+ item.c.writeback.Rename(id, newName)++ return err}