Stop removing failed upload to cloud storage remotes - fixes #559

We do remove a partially written file on local so we don't have
corrupted files lying around.
This commit is contained in:
Nick Craig-Wood
2016-11-04 21:34:25 +00:00
parent 154e91bb23
commit 441951a93b
16 changed files with 54 additions and 11 deletions
+9 -5
View File
@@ -665,12 +665,16 @@ func (o *Object) Update(in io.Reader, src fs.ObjectInfo) error {
in = io.TeeReader(in, hash)
_, err = io.Copy(out, in)
outErr := out.Close()
if err != nil {
return err
closeErr := out.Close()
if err == nil {
err = closeErr
}
if outErr != nil {
return outErr
if err != nil {
fs.Debug(o, "Removing partially written file on error: %v", err)
if removeErr := os.Remove(o.path); removeErr != nil {
fs.ErrorLog(o, "Failed to remove partially written file: %v", removeErr)
}
return err
}
// All successful so update the hashes