mirror of
https://github.com/rclone/rclone.git
synced 2025-01-03 12:59:32 +01:00
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:
parent
80bccacd83
commit
e3a77f218b
@ -266,22 +266,6 @@ func equal(ctx context.Context, src fs.ObjectInfo, dst fs.Object, opt equalOpt)
|
|||||||
return true
|
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
|
// OverrideRemote is a wrapper to override the Remote for an
|
||||||
// ObjectInfo
|
// ObjectInfo
|
||||||
type OverrideRemote struct {
|
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())
|
err = errors.Errorf("corrupted on transfer: sizes differ %d vs %d", src.Size(), dst.Size())
|
||||||
fs.Errorf(dst, "%v", err)
|
fs.Errorf(dst, "%v", err)
|
||||||
err = fs.CountError(err)
|
err = fs.CountError(err)
|
||||||
removeFailedCopy(ctx, dst)
|
|
||||||
return newDst, err
|
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)
|
err = errors.Errorf("corrupted on transfer: %v hash differ %q vs %q", hashType, srcSum, dstSum)
|
||||||
fs.Errorf(dst, "%v", err)
|
fs.Errorf(dst, "%v", err)
|
||||||
err = fs.CountError(err)
|
err = fs.CountError(err)
|
||||||
removeFailedCopy(ctx, dst)
|
|
||||||
return newDst, err
|
return newDst, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user