operations: don't remove destination files on errored transfers

See: https://forum.rclone.org/t/transfer-on-mega-in-ftp-mode-is-not-working/24642/7
This commit is contained in:
Nick Craig-Wood 2021-06-16 12:02:45 +01:00
parent 80bccacd83
commit e3a77f218b

View File

@ -266,22 +266,6 @@ func equal(ctx context.Context, src fs.ObjectInfo, dst fs.Object, opt equalOpt)
return true
}
// Used to remove a failed copy
//
// Returns whether the file was successfully removed or not
func removeFailedCopy(ctx context.Context, dst fs.Object) bool {
if dst == nil {
return false
}
fs.Infof(dst, "Removing failed copy")
removeErr := dst.Remove(ctx)
if removeErr != nil {
fs.Infof(dst, "Failed to remove failed copy: %s", removeErr)
return false
}
return true
}
// OverrideRemote is a wrapper to override the Remote for an
// ObjectInfo
type OverrideRemote struct {
@ -515,7 +499,6 @@ func Copy(ctx context.Context, f fs.Fs, dst fs.Object, remote string, src fs.Obj
err = errors.Errorf("corrupted on transfer: sizes differ %d vs %d", src.Size(), dst.Size())
fs.Errorf(dst, "%v", err)
err = fs.CountError(err)
removeFailedCopy(ctx, dst)
return newDst, err
}
@ -527,7 +510,6 @@ func Copy(ctx context.Context, f fs.Fs, dst fs.Object, remote string, src fs.Obj
err = errors.Errorf("corrupted on transfer: %v hash differ %q vs %q", hashType, srcSum, dstSum)
fs.Errorf(dst, "%v", err)
err = fs.CountError(err)
removeFailedCopy(ctx, dst)
return newDst, err
}
}