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.
This commit is contained in:
parent
f57e92b9a5
commit
c3d0f68923
1 changed files with 1 additions and 1 deletions
|
@ -170,7 +170,7 @@ func (fh *RWFileHandle) openPending(truncate bool) (err error) {
|
||||||
// Windows doesn't seem to deal well with O_TRUNC and
|
// Windows doesn't seem to deal well with O_TRUNC and
|
||||||
// certain access modes so so truncate the file if it
|
// certain access modes so so truncate the file if it
|
||||||
// exists in these cases.
|
// 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
|
cacheFileOpenFlags &^= os.O_TRUNC
|
||||||
_, err = os.Stat(fh.osPath)
|
_, err = os.Stat(fh.osPath)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
Loading…
Reference in a new issue