forked from TrueCloudLab/rclone
drive: switch to insert from update when a failed copy deletes the upload
This commit is contained in:
parent
09d71239b6
commit
5cc5429f99
1 changed files with 17 additions and 8 deletions
|
@ -109,14 +109,19 @@ func MimeType(o Object) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used to remove a failed copy
|
// Used to remove a failed copy
|
||||||
func removeFailedCopy(dst Object) {
|
//
|
||||||
if dst != nil {
|
// Returns whether the file was succesfully removed or not
|
||||||
Debug(dst, "Removing failed copy")
|
func removeFailedCopy(dst Object) bool {
|
||||||
removeErr := dst.Remove()
|
if dst == nil {
|
||||||
if removeErr != nil {
|
return false
|
||||||
Debug(dst, "Failed to remove failed copy: %s", removeErr)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Debug(dst, "Removing failed copy")
|
||||||
|
removeErr := dst.Remove()
|
||||||
|
if removeErr != nil {
|
||||||
|
Debug(dst, "Failed to remove failed copy: %s", removeErr)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy src object to dst or f if nil
|
// Copy src object to dst or f if nil
|
||||||
|
@ -150,7 +155,11 @@ tryAgain:
|
||||||
if r, ok := err.(Retry); ok && r.Retry() && tries < maxTries {
|
if r, ok := err.(Retry); ok && r.Retry() && tries < maxTries {
|
||||||
tries++
|
tries++
|
||||||
Log(src, "Received error: %v - retrying %d/%d", err, tries, maxTries)
|
Log(src, "Received error: %v - retrying %d/%d", err, tries, maxTries)
|
||||||
removeFailedCopy(dst)
|
if removeFailedCopy(dst) {
|
||||||
|
// If we removed dst, then nil it out and note we are not updating
|
||||||
|
dst = nil
|
||||||
|
doUpdate = false
|
||||||
|
}
|
||||||
goto tryAgain
|
goto tryAgain
|
||||||
}
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
Loading…
Reference in a new issue