"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 creation of files when truncating #2083
Nick Craig-Woodf57e92b9a566
diff --git a/vfs/read_write.go b/vfs/read_write.goindex ade4375e1..69913ae3d 100644--- a/vfs/read_write.go+++ b/vfs/read_write.go@@ -3,6 +3,7 @@ package vfsimport ("fmt""io"+ "io/ioutil""os""runtime""sync"@@ -159,9 +160,12 @@ func (fh *RWFileHandle) openPending(truncate bool) (err error) {// Set the size to 0 since we are truncating and flag we need to write it backfh.file.setSize(0)fh.writeCalled = true- if fh.flags&os.O_CREATE != 0 && fh.file.exists() {- // create and empty file if it exists on the source- cacheFileOpenFlags |= os.O_CREATE+ if fh.flags&os.O_CREATE == 0 && fh.file.exists() {+ // create an empty file if it exists on the source+ err = ioutil.WriteFile(fh.osPath, []byte{}, 0600)+ if err != nil {+ return errors.Wrap(err, "cache open failed to create zero length file")+ }}// Windows doesn't seem to deal well with O_TRUNC and// certain access modes so so truncate the file if it