forked from TrueCloudLab/rclone
vfs: make sure write only handles never truncate files they shouldn't
This commit is contained in:
parent
76b151984c
commit
3fb4fe31d2
5 changed files with 94 additions and 20 deletions
|
@ -111,7 +111,7 @@ func TestFileOpenWrite(t *testing.T) {
|
|||
defer r.Finalise()
|
||||
vfs, file, _ := fileCreate(t, r)
|
||||
|
||||
fd, err := file.OpenWrite()
|
||||
fd, err := file.OpenWrite(os.O_WRONLY | os.O_TRUNC)
|
||||
require.NoError(t, err)
|
||||
|
||||
newContents := []byte("this is some new contents")
|
||||
|
@ -123,7 +123,7 @@ func TestFileOpenWrite(t *testing.T) {
|
|||
assert.Equal(t, int64(25), file.Size())
|
||||
|
||||
vfs.Opt.ReadOnly = true
|
||||
_, err = file.OpenWrite()
|
||||
_, err = file.OpenWrite(os.O_WRONLY | os.O_TRUNC)
|
||||
assert.Equal(t, EROFS, err)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue