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 {