Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve 'Key not found: path' when syncing from some shared folders #211

Merged
merged 6 commits into from
Oct 29, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions src/sync.d
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ private bool hasParentReferenceId(const ref JSONValue item)
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)
{
return ("malware" in item) != null;
Expand Down Expand Up @@ -459,9 +464,11 @@ final class SyncEngine
if (item["parentReference"]["driveId"].str != defaultDriveId) {
// 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:";
if (item["parentReference"]["path"].str == sharedDriveRootPath) {
// The drive path matches what a shared folder root item would equal
isRoot = true;
if (hasParentReferencePath(item)) {
if (item["parentReference"]["path"].str == sharedDriveRootPath) {
// The drive path matches what a shared folder root item would equal
isRoot = true;
}
}
}
}
Expand All @@ -473,7 +480,11 @@ final class SyncEngine
applyDifference(item, driveId, isRoot);
} else {
// 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:
// 1. 'item id' matches 'id'
// 2. 'parentReference id' matches 'id'
Expand Down Expand Up @@ -898,7 +909,7 @@ final class SyncEngine
uploadNewFile(path);
} else {
log.vlog("The directory has not changed");
// loop trough the children
// loop through the children
foreach (Item child; itemdb.selectChildren(item.driveId, item.id)) {
uploadDifferences(child);
}
Expand All @@ -924,12 +935,14 @@ final class SyncEngine
uploadNewFile(path);
} else {
log.vlog("The directory has not changed");
// continue trough the linked folder
// continue through the linked folder
assert(item.remoteDriveId && item.remoteId);
Item remoteItem;
bool found = itemdb.selectById(item.remoteDriveId, item.remoteId, remoteItem);
assert(found);
uploadDifferences(remoteItem);
if(found){
// item was found in the database
uploadDifferences(remoteItem);
}
}
} else {
log.vlog("The directory has been deleted");
Expand Down