From c3d0f68923ce03402be668f1958cb67f97b8aad9 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Mon, 26 Feb 2018 19:46:38 +0000 Subject: [PATCH] vfs: fix truncation work-around on Windows This no longer needs to deal with O_RDONLY and O_TRUNC since we disallow this earlier. This also fixes the code to just do it for O_APPEND, not for everything. --- vfs/read_write.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vfs/read_write.go b/vfs/read_write.go index 69913ae3d..9918cd3d0 100644 --- a/vfs/read_write.go +++ b/vfs/read_write.go @@ -170,7 +170,7 @@ func (fh *RWFileHandle) openPending(truncate bool) (err error) { // Windows doesn't seem to deal well with O_TRUNC and // certain access modes so so truncate the file if it // exists in these cases. - if runtime.GOOS == "windows" && (fh.flags&accessModeMask == os.O_RDONLY || fh.flags|os.O_APPEND != 0) { + if runtime.GOOS == "windows" && fh.flags&os.O_APPEND != 0 { cacheFileOpenFlags &^= os.O_TRUNC _, err = os.Stat(fh.osPath) if err == nil {