mirror of
https://github.com/abraunegg/onedrive
synced 2024-05-01 21:52:50 +02:00
Resolve #341 '--single-directory' edge case
* Resolve where '--single-directory' is used to sync a single directory, but a file / folder is 'moved' on OneDrive to outside the scope of the focus of the '--single-directory' path. Before this change, the file would remain in the local path (original location) whilst it would reside in the new OneDrive path. This patch looks for this mis match and deletes the local file / folder to reflect it is no longer in the same OneDrive path.
This commit is contained in:
parent
6fe06d03ac
commit
ccd4dfbaf7
24
src/sync.d
24
src/sync.d
|
@ -358,6 +358,30 @@ final class SyncEngine
|
|||
if ( (item["id"].str == id) || (item["parentReference"]["id"].str == id) || (canFind(thisItemPath, syncFolderName)) ){
|
||||
// This is a change we want to apply
|
||||
applyDifference(item, driveId, isRoot);
|
||||
} else {
|
||||
// No item ID match or folder sync match
|
||||
// Before discarding change - does this ID still exist on OneDrive - as in IS this
|
||||
// potentially a --single-directory sync and the user 'moved' the file out of the 'sync-dir' to another OneDrive folder
|
||||
// This is a corner edge case - https://github.com/skilion/onedrive/issues/341
|
||||
JSONValue oneDriveMovedNotDeleted;
|
||||
try {
|
||||
oneDriveMovedNotDeleted = onedrive.getPathDetailsById(item["id"].str);
|
||||
} catch (OneDriveException e) {
|
||||
if (e.httpStatusCode == 404) {
|
||||
// No .. that ID is GONE
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Yes .. ID is still on OneDrive but elsewhere .... #341 edge case handling
|
||||
// What is the original local path for this ID in the database? Does it match 'syncFolderName'
|
||||
string originalLocalPath = itemdb.computePath(driveId, item["id"].str);
|
||||
|
||||
if (canFind(originalLocalPath, syncFolderName)){
|
||||
// This 'change' relates to an item that WAS in 'syncFolderName' but is now
|
||||
// stored elsewhere on OneDrive - outside the path we are syncing from
|
||||
// Remove this item locally as it's local path is now obsolete
|
||||
idsToDelete ~= [driveId, item["id"].str];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue