mirror of
https://github.com/abraunegg/onedrive
synced 2024-06-19 06:05:18 +02:00
Resolve 'Key not found: path' when syncing from some shared folders (#211)
* Add a check to validate if the parentReference object has a path object * Fix spelling error - trough -> through * Only upload changes on remote folder if the item is in the database - dont assert if false
This commit is contained in:
parent
76ac8d3a24
commit
eb2cbfd0a8
29
src/sync.d
29
src/sync.d
|
@ -45,6 +45,11 @@ private bool hasParentReferenceId(const ref JSONValue item)
|
||||||
return ("id" in item["parentReference"]) != null;
|
return ("id" in item["parentReference"]) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool hasParentReferencePath(const ref JSONValue item)
|
||||||
|
{
|
||||||
|
return ("path" in item["parentReference"]) != null;
|
||||||
|
}
|
||||||
|
|
||||||
private bool isMalware(const ref JSONValue item)
|
private bool isMalware(const ref JSONValue item)
|
||||||
{
|
{
|
||||||
return ("malware" in item) != null;
|
return ("malware" in item) != null;
|
||||||
|
@ -459,9 +464,11 @@ final class SyncEngine
|
||||||
if (item["parentReference"]["driveId"].str != defaultDriveId) {
|
if (item["parentReference"]["driveId"].str != defaultDriveId) {
|
||||||
// The change parentReference driveId does not match the defaultDriveId - this could be a Shared Folder root item
|
// The change parentReference driveId does not match the defaultDriveId - this could be a Shared Folder root item
|
||||||
string sharedDriveRootPath = "/drives/" ~ item["parentReference"]["driveId"].str ~ "/root:";
|
string sharedDriveRootPath = "/drives/" ~ item["parentReference"]["driveId"].str ~ "/root:";
|
||||||
if (item["parentReference"]["path"].str == sharedDriveRootPath) {
|
if (hasParentReferencePath(item)) {
|
||||||
// The drive path matches what a shared folder root item would equal
|
if (item["parentReference"]["path"].str == sharedDriveRootPath) {
|
||||||
isRoot = true;
|
// The drive path matches what a shared folder root item would equal
|
||||||
|
isRoot = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -473,7 +480,11 @@ final class SyncEngine
|
||||||
applyDifference(item, driveId, isRoot);
|
applyDifference(item, driveId, isRoot);
|
||||||
} else {
|
} else {
|
||||||
// What is this item's path?
|
// What is this item's path?
|
||||||
thisItemPath = item["parentReference"]["path"].str;
|
if (hasParentReferencePath(item)) {
|
||||||
|
thisItemPath = item["parentReference"]["path"].str;
|
||||||
|
} else {
|
||||||
|
thisItemPath = "";
|
||||||
|
}
|
||||||
// Check this item's path to see if this is a change on the path we want:
|
// Check this item's path to see if this is a change on the path we want:
|
||||||
// 1. 'item id' matches 'id'
|
// 1. 'item id' matches 'id'
|
||||||
// 2. 'parentReference id' matches 'id'
|
// 2. 'parentReference id' matches 'id'
|
||||||
|
@ -898,7 +909,7 @@ final class SyncEngine
|
||||||
uploadNewFile(path);
|
uploadNewFile(path);
|
||||||
} else {
|
} else {
|
||||||
log.vlog("The directory has not changed");
|
log.vlog("The directory has not changed");
|
||||||
// loop trough the children
|
// loop through the children
|
||||||
foreach (Item child; itemdb.selectChildren(item.driveId, item.id)) {
|
foreach (Item child; itemdb.selectChildren(item.driveId, item.id)) {
|
||||||
uploadDifferences(child);
|
uploadDifferences(child);
|
||||||
}
|
}
|
||||||
|
@ -924,12 +935,14 @@ final class SyncEngine
|
||||||
uploadNewFile(path);
|
uploadNewFile(path);
|
||||||
} else {
|
} else {
|
||||||
log.vlog("The directory has not changed");
|
log.vlog("The directory has not changed");
|
||||||
// continue trough the linked folder
|
// continue through the linked folder
|
||||||
assert(item.remoteDriveId && item.remoteId);
|
assert(item.remoteDriveId && item.remoteId);
|
||||||
Item remoteItem;
|
Item remoteItem;
|
||||||
bool found = itemdb.selectById(item.remoteDriveId, item.remoteId, remoteItem);
|
bool found = itemdb.selectById(item.remoteDriveId, item.remoteId, remoteItem);
|
||||||
assert(found);
|
if(found){
|
||||||
uploadDifferences(remoteItem);
|
// item was found in the database
|
||||||
|
uploadDifferences(remoteItem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.vlog("The directory has been deleted");
|
log.vlog("The directory has been deleted");
|
||||||
|
|
Loading…
Reference in a new issue