onedrive: make moving between drives fall back to copying then deleting

This commit is contained in:
Cnly 2018-12-26 15:57:16 +08:00
parent 7d87386d58
commit 64e303321b

View file

@ -989,11 +989,17 @@ func (f *Fs) Move(src fs.Object, remote string) (fs.Object, error) {
return nil, err
}
id, dstDriveID, _ := parseNormalizedID(directoryID)
if dstDriveID != srcObj.fs.driveID {
// https://docs.microsoft.com/en-us/graph/api/driveitem-move?view=graph-rest-1.0
// "Items cannot be moved between Drives using this request."
return nil, fs.ErrorCantMove
}
// Move the object
opts := newOptsCall(srcObj.id, "PATCH", "")
id, dstDriveID, _ := parseNormalizedID(directoryID)
move := api.MoveItemRequest{
Name: replaceReservedChars(leaf),
ParentReference: &api.ItemReference{
@ -1076,6 +1082,12 @@ func (f *Fs) DirMove(src fs.Fs, srcRemote, dstRemote string) error {
}
parsedDstDirID, dstDriveID, _ := parseNormalizedID(dstDirectoryID)
if dstDriveID != srcFs.driveID {
// https://docs.microsoft.com/en-us/graph/api/driveitem-move?view=graph-rest-1.0
// "Items cannot be moved between Drives using this request."
return fs.ErrorCantDirMove
}
// Check destination does not exist
if dstRemote != "" {
_, err = f.dirCache.FindDir(dstRemote, false)