From 321b6da7af622396268053d998b92574c6abc40c Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sat, 18 Nov 2017 11:55:39 +0000 Subject: [PATCH] vfs: don't remove file from writers until it is transferred This means that the list of active writers is up to date --- vfs/read_write.go | 3 ++- vfs/write.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) 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 {