Revert "Switch to using list_children for an item id's children"

This reverts commit fedaedacd7.
This commit is contained in:
abraunegg 2018-04-21 07:19:04 +10:00
parent 3d224d0595
commit 8a059dc0e1
2 changed files with 21 additions and 14 deletions

View file

@ -114,15 +114,16 @@ final class OneDriveApi
return get(url);
}
// https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/driveitem_list_children
JSONValue viewChildrenById(const(char)[] driveId, const(char)[] id)
// https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_delta
JSONValue viewChangesByPath(const(char)[] path, const(char)[] deltaLink)
{
// Get a list of children for a given item id
// Returns a value array where each array element has the following:
// id,name,eTag,cTag,file,folder,fileSystemInfo,remoteItem,parentReference
checkAccessTokenExpired();
// GET /drives/{drive-id}/items/{item-id}/children
const(char)[] url = driveByIdUrl ~ driveId ~ "/items/" ~ id ~ "/children";
const(char)[] url = deltaLink;
if (url == null) {
if (path == ".") url = driveUrl ~ "/root/delta";
else url = itemByPathUrl ~ encodeComponent(path) ~ ":/delta";
url ~= "?select=id,name,eTag,cTag,deleted,file,folder,root,fileSystemInfo,remoteItem,parentReference";
}
return get(url);
}

View file

@ -181,14 +181,13 @@ final class SyncEngine
if (e.httpStatusCode == 404) {
// The directory was not found
log.vlog("ERROR: The requested single directory to sync was not found on OneDrive");
// We are expecting this directory however as this is a single directory sync
uploadCreateDir(path);
return;
}
}
// OK - it should exist, get the driveId and rootId for this folder
log.vlog("Checking for differences from OneDrive ...");
// If the OneDrive Root is not in the local database, creating a remote folder in the selected path will fail
// If the OneDrive Root is not in the local database, creating a remote folder will fail
checkDatabaseForOneDriveRoot();
// Configure driveID and folderId
@ -289,10 +288,17 @@ final class SyncEngine
log.vlog("Applying changes of Path ID: " ~ id);
for (;;) {
// Will provide a JSON of children of the item id
changes = onedrive.viewChildrenById(driveId, id);
// For each 'value' item (child resource ..
try {
changes = onedrive.viewChangesById(driveId, id, deltaLink);
} catch (OneDriveException e) {
if (e.httpStatusCode == 410) {
log.vlog("Delta link expired, resyncing...");
deltaLink = null;
continue;
} else {
throw e;
}
}
foreach (item; changes["value"].array) {
bool isRoot = (id == defaultRootId); // fix for https://github.com/skilion/onedrive/issues/269
// Apply the change