"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 IO error by recreating the cache file if it has been removed
Nick Craig-Wood6e0cde076a60
diff --git a/vfs/vfscache/item.go b/vfs/vfscache/item.goindex d82e90da7..b65cba924 100644--- a/vfs/vfscache/item.go+++ b/vfs/vfscache/item.go@@ -471,7 +471,10 @@ func (item *Item) _createFile(osPath string) (err error) {}item.modified = false// t0 := time.Now()- fd, err := file.OpenFile(osPath, os.O_RDWR, 0600)+ // Use O_CREATE so the cache file is recreated if it has been removed+ // underneath us (e.g. _checkObject dropped a stale entry, or an external+ // deletion), rather than failing the open with a hard IO error.+ fd, err := file.OpenFile(osPath, os.O_RDWR|os.O_CREATE, 0600)// fs.Debugf(item.name, "OpenFile took %v", time.Since(t0))if err != nil {return fmt.Errorf("vfs cache item: open failed: %w", err)@@ -560,6 +563,10 @@ func (item *Item) open(o fs.Object) (err error) {return nil}fs.Debugf(item.name, "vfs cache: cache file vanished during grace period, recreating")+ // The backing file is gone, so any ranges are invalid.+ item.info.Rs = nil+ // It also can't be dirty if the data no longer exists.+ item.info.Dirty = falseif item.fd != nil {_ = item.fd.Close()item.fd = nil