Stop --track-renames deleting case folded source files - fixes #1094
What was happening is that when Move was implemented as Copy + Delete, MoveFile was seeing the files didn't need transferring (because they were identical) then deleted the source. The fix uses Move instead and patches onedrive to disallow a case folded identical copy (which errors with 500 error)
This commit is contained in:
parent
f40443359d
commit
e59dc81658
2 changed files with 11 additions and 1 deletions
|
@ -593,17 +593,23 @@ func (s *syncCopyMove) tryRename(src Object) bool {
|
||||||
Stats.Checking(src.Remote())
|
Stats.Checking(src.Remote())
|
||||||
defer Stats.DoneChecking(src.Remote())
|
defer Stats.DoneChecking(src.Remote())
|
||||||
|
|
||||||
|
// Calculate the hash of the src object
|
||||||
hash := s.renameHash(src)
|
hash := s.renameHash(src)
|
||||||
if hash == "" {
|
if hash == "" {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get a match on fdst
|
||||||
dst := s.popRenameMap(hash)
|
dst := s.popRenameMap(hash)
|
||||||
if dst == nil {
|
if dst == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
err := MoveFile(s.fdst, s.fdst, src.Remote(), dst.Remote())
|
// Find dst object we are about to overwrite if it exists
|
||||||
|
dstOverwritten, _ := s.fdst.NewObject(src.Remote())
|
||||||
|
|
||||||
|
// Rename dst to have name src.Remote()
|
||||||
|
err := Move(s.fdst, dstOverwritten, src.Remote(), dst)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Debugf(src, "Failed to rename to %q: %v", dst.Remote(), err)
|
Debugf(src, "Failed to rename to %q: %v", dst.Remote(), err)
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -600,6 +600,10 @@ func (f *Fs) Copy(src fs.Object, remote string) (fs.Object, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if strings.ToLower(srcObj.remote) == strings.ToLower(remote) {
|
||||||
|
return nil, errors.Errorf("can't copy %q -> %q as are same name when lowercase", srcObj.remote, remote)
|
||||||
|
}
|
||||||
|
|
||||||
// Create temporary object
|
// Create temporary object
|
||||||
dstObj, leaf, directoryID, err := f.createObject(remote, srcObj.modTime, srcObj.size)
|
dstObj, leaf, directoryID, err := f.createObject(remote, srcObj.modTime, srcObj.size)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Add table
Reference in a new issue