Fix Move when underlying remote returns ErrorCantMove

This commit is contained in:
Nick Craig-Wood 2016-08-23 17:40:04 +01:00
parent e6a0521ca2
commit a54806e5c1

View File

@ -262,6 +262,17 @@ func (s *syncCopyMove) pairMover(in ObjectPairChan, fdst Fs, wg *sync.WaitGroup)
src := pair.src src := pair.src
dst := pair.dst dst := pair.dst
Stats.Transferring(src.Remote()) Stats.Transferring(src.Remote())
doCopy := func() {
// Copy dst <- src
err := Copy(fdst, dst, src)
s.processError(err)
if err != nil {
ErrorLog(src, "Not deleting as copy failed: %v", err)
} else {
// Delete src if no error on copy
s.processError(DeleteFile(src))
}
}
if Config.DryRun { if Config.DryRun {
Log(src, "Not moving as --dry-run") Log(src, "Not moving as --dry-run")
} else if haveMover && src.Fs().Name() == fdst.Name() { } else if haveMover && src.Fs().Name() == fdst.Name() {
@ -272,22 +283,22 @@ func (s *syncCopyMove) pairMover(in ObjectPairChan, fdst Fs, wg *sync.WaitGroup)
// Move dst <- src // Move dst <- src
_, err := fdstMover.Move(src, src.Remote()) _, err := fdstMover.Move(src, src.Remote())
if err != nil { if err != nil {
Stats.Error() // If this remote can't do moves,
ErrorLog(dst, "Couldn't move: %v", err) // then set the flag and copy
s.processError(err) if err == ErrorCantMove {
Debug(src, "Can't move, switching to copy")
haveMover = false
doCopy()
} else {
Stats.Error()
ErrorLog(dst, "Couldn't move: %v", err)
s.processError(err)
}
} else { } else {
Debug(src, "Moved") Debug(src, "Moved")
} }
} else { } else {
// Copy dst <- src doCopy()
err := Copy(fdst, dst, src)
s.processError(err)
if err != nil {
ErrorLog(src, "Not deleting as copy failed: %v", err)
} else {
// Delete src if no error on copy
s.processError(DeleteFile(src))
}
} }
Stats.DoneTransferring(src.Remote()) Stats.DoneTransferring(src.Remote())
case <-s.abort: case <-s.abort: