1
0
mirror of https://github.com/rclone/rclone.git synced 2026-01-06 18:43:50 +00:00

vfs: fix writing to a read only directory creating spurious directory entries

Before this fix, when a write to a read only directory failed, rclone
would leav spurious directory entries in the directory.

This confuses `rclone serve webdav` into giving this error

    http: superfluous response.WriteHeader

This fixes the VFS layer to remove any directory entries where the
file creation did not succeed.

Fixes #5702
This commit is contained in:
WeidiDeng
2021-11-10 16:49:09 +08:00
committed by Nick Craig-Wood
parent fda06fc17d
commit 7771aaacf6
3 changed files with 69 additions and 4 deletions

View File

@@ -203,6 +203,11 @@ func (fh *WriteFileHandle) close() (err error) {
if err == nil {
fh.file.setObject(fh.o)
err = writeCloseErr
} else {
// Remove vfs file entry when no object is present
if fh.file.getObject() == nil {
_ = fh.file.Remove()
}
}
return err
}