webdav: don't leave a partially uploaded file behind on error

This commit is contained in:
Simon Ser 2024-12-09 09:19:16 +01:00
parent 7f8c17ad71
commit 93fee5bcf0

View File

@ -132,9 +132,11 @@ func (fs LocalFileSystem) Create(ctx context.Context, name string, body io.ReadC
defer wc.Close() defer wc.Close()
if _, err := io.Copy(wc, body); err != nil { if _, err := io.Copy(wc, body); err != nil {
os.Remove(p)
return nil, false, err return nil, false, err
} }
if err := wc.Close(); err != nil { if err := wc.Close(); err != nil {
os.Remove(p)
return nil, false, err return nil, false, err
} }