forked from TrueCloudLab/rclone
parent
baf9ee5cf7
commit
f57e92b9a5
1 changed files with 7 additions and 3 deletions
|
@ -3,6 +3,7 @@ package vfs
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -159,9 +160,12 @@ func (fh *RWFileHandle) openPending(truncate bool) (err error) {
|
||||||
// Set the size to 0 since we are truncating and flag we need to write it back
|
// Set the size to 0 since we are truncating and flag we need to write it back
|
||||||
fh.file.setSize(0)
|
fh.file.setSize(0)
|
||||||
fh.writeCalled = true
|
fh.writeCalled = true
|
||||||
if fh.flags&os.O_CREATE != 0 && fh.file.exists() {
|
if fh.flags&os.O_CREATE == 0 && fh.file.exists() {
|
||||||
// create and empty file if it exists on the source
|
// create an empty file if it exists on the source
|
||||||
cacheFileOpenFlags |= os.O_CREATE
|
err = ioutil.WriteFile(fh.osPath, []byte{}, 0600)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "cache open failed to create zero length file")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 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
|
||||||
|
|
Loading…
Reference in a new issue