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: don't remove file from writers until it is transferred

Nick Craig-Wood321b6da7af62
diff --git a/vfs/read_write.go b/vfs/read_write.go
index fcaf65569..68c2ae569 100644
--- a/vfs/read_write.go
+++ b/vfs/read_write.go
@@ -143,7 +143,8 @@ func (fh *RWFileHandle) close() (err error) {
fh.closed = true
rdwrMode := fh.flags & accessModeMask
if rdwrMode != os.O_RDONLY {
- fh.file.delWriter(fh)
+ // leave writer open until file is transferred
+ defer fh.file.delWriter(fh)
}
if !fh.opened {
// If read only then return
diff --git a/vfs/write.go b/vfs/write.go
index ce9d6b914..3c107f486 100644
--- a/vfs/write.go
+++ b/vfs/write.go
@@ -151,7 +151,8 @@ func (fh *WriteFileHandle) close() error {
return ECLOSED
}
fh.closed = true
- fh.file.delWriter(fh)
+ // leave writer open until file is transferred
+ defer fh.file.delWriter(fh)
writeCloseErr := fh.pipeWriter.Close()
err := <-fh.result
if err == nil {