sync: when using --backup-dir don't delete files if we can't set their modtime
This is a problem when syncing a file which just needed its modtime set with dropbox which can't set the mod time of a file without re-uploading it. Before this change we would delete the file, then the server side move would fail moving the file to the backup-dir because it no longer existed. After this change the destination file is moved to the backup-dir instead of being deleted and the new file is uploaded. Fixes #2134
This commit is contained in:
@@ -178,9 +178,13 @@ func equal(src fs.ObjectInfo, dst fs.Object, sizeOnly, checkSum bool) bool {
|
||||
return false
|
||||
} else if err == fs.ErrorCantSetModTimeWithoutDelete {
|
||||
fs.Debugf(dst, "src and dst identical but can't set mod time without deleting and re-uploading")
|
||||
err = dst.Remove()
|
||||
if err != nil {
|
||||
fs.Errorf(dst, "failed to delete before re-upload: %v", err)
|
||||
// Remove the file if BackupDir isn't set. If BackupDir is set we would rather have the old file
|
||||
// put in the BackupDir than deleted which is what will happen if we don't delete it.
|
||||
if fs.Config.BackupDir == "" {
|
||||
err = dst.Remove()
|
||||
if err != nil {
|
||||
fs.Errorf(dst, "failed to delete before re-upload: %v", err)
|
||||
}
|
||||
}
|
||||
return false
|
||||
} else if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user