mirror of
https://github.com/1f349/go-webdav.git
synced 2025-01-31 03:36:37 +00:00
webdav: don't leave a partially uploaded file behind on error
This commit is contained in:
parent
7f8c17ad71
commit
93fee5bcf0
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user