"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: fix "file already exists" error for stale cache files
Nick Craig-Wood2347762b0d0c
diff --git a/vfs/read_write.go b/vfs/read_write.goindex 03d990c3a..b16eb663f 100644--- a/vfs/read_write.go+++ b/vfs/read_write.go@@ -36,7 +36,7 @@ func newRWFileHandle(d *Dir, f *File, flags int) (fh *RWFileHandle, err error) {// get an item to represent this from the cacheitem := d.vfs.cache.Item(f.Path())- exists := f.exists() || item.Exists()+ exists := f.exists() || (item.Exists() && !item.WrittenBack())// if O_CREATE and O_EXCL are set and if path already exists, then return EEXISTif flags&(os.O_CREATE|os.O_EXCL) == os.O_CREATE|os.O_EXCL && exists {diff --git a/vfs/vfscache/item.go b/vfs/vfscache/item.goindex 9163e8ce9..158e583f2 100644--- a/vfs/vfscache/item.go+++ b/vfs/vfscache/item.go@@ -808,6 +808,13 @@ func (item *Item) _checkObject(o fs.Object) error {return nil}+// WrittenBack checks to see if the item has been written back or not+func (item *Item) WrittenBack() bool {+ item.mu.Lock()+ defer item.mu.Unlock()+ return item.info.Fingerprint != ""+}+// remove the cached file//// call with lock held