mirror of
https://github.com/abraunegg/onedrive
synced 2024-06-15 20:25:18 +02:00
Update PR
* Update PR
This commit is contained in:
parent
760b3c81b2
commit
54b3d52703
12
src/config.d
12
src/config.d
|
@ -319,9 +319,9 @@ class ApplicationConfig {
|
||||||
boolValues["webhook_enabled"] = false;
|
boolValues["webhook_enabled"] = false;
|
||||||
|
|
||||||
// Print in debug the application version as soon as possible
|
// Print in debug the application version as soon as possible
|
||||||
|
//log.vdebug("Application Version: ", strip(import("version")));
|
||||||
//log.vdebug("Application Version: ", strip(import("version")));
|
string tempVersion = "v2.5.0-alpha-0" ~ " GitHub version: " ~ strip(import("version"));
|
||||||
log.vdebug("Application Version: v2.5.0-alpha-0");
|
log.vdebug("Application Version: ", tempVersion);
|
||||||
|
|
||||||
// EXPAND USERS HOME DIRECTORY
|
// EXPAND USERS HOME DIRECTORY
|
||||||
// Determine the users home directory.
|
// Determine the users home directory.
|
||||||
|
@ -1089,7 +1089,11 @@ class ApplicationConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display application version
|
// Display application version
|
||||||
writeln("onedrive version = ", strip(import("version")));
|
//writeln("onedrive version = ", strip(import("version")));
|
||||||
|
|
||||||
|
string tempVersion = "v2.5.0-alpha-0" ~ " GitHub version: " ~ strip(import("version"));
|
||||||
|
writeln("onedrive version = ", tempVersion);
|
||||||
|
|
||||||
// Display all of the pertinent configuration options
|
// Display all of the pertinent configuration options
|
||||||
writeln("Config path = ", configDirName);
|
writeln("Config path = ", configDirName);
|
||||||
// Does a config file exist or are we using application defaults
|
// Does a config file exist or are we using application defaults
|
||||||
|
|
|
@ -110,7 +110,8 @@ int main(string[] cliArgs) {
|
||||||
// Print the version and exit
|
// Print the version and exit
|
||||||
if (printVersion) {
|
if (printVersion) {
|
||||||
//writeln("onedrive ", strip(import("version")));
|
//writeln("onedrive ", strip(import("version")));
|
||||||
writeln("onedrive v2.5.0-alpha-0");
|
string tempVersion = "v2.5.0-alpha-0" ~ " GitHub version: " ~ strip(import("version"));
|
||||||
|
writeln(tempVersion);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
} catch (GetOptException e) {
|
} catch (GetOptException e) {
|
||||||
|
|
121
src/sync.d
121
src/sync.d
|
@ -294,7 +294,7 @@ class SyncEngine {
|
||||||
Thread.sleep(dur!"seconds"(30));
|
Thread.sleep(dur!"seconds"(30));
|
||||||
}
|
}
|
||||||
// re-try original request - retried for 429 and 504 - but loop back calling this function
|
// re-try original request - retried for 429 and 504 - but loop back calling this function
|
||||||
log.vdebug("Retrying Query: getDefaultDriveDetails()");
|
log.vdebug("Retrying Function: getDefaultDriveDetails()");
|
||||||
getDefaultDriveDetails();
|
getDefaultDriveDetails();
|
||||||
} else {
|
} else {
|
||||||
// Default operation if not 408,429,503,504 errors
|
// Default operation if not 408,429,503,504 errors
|
||||||
|
@ -458,7 +458,7 @@ class SyncEngine {
|
||||||
Thread.sleep(dur!"seconds"(30));
|
Thread.sleep(dur!"seconds"(30));
|
||||||
}
|
}
|
||||||
// re-try original request - retried for 429, 503, 504 - but loop back calling this function
|
// re-try original request - retried for 429, 503, 504 - but loop back calling this function
|
||||||
log.vdebug("Retrying Query: getDefaultRootDetails()");
|
log.vdebug("Retrying Function: getDefaultRootDetails()");
|
||||||
getDefaultRootDetails();
|
getDefaultRootDetails();
|
||||||
} else {
|
} else {
|
||||||
// Default operation if not 408,429,503,504 errors
|
// Default operation if not 408,429,503,504 errors
|
||||||
|
@ -3657,10 +3657,8 @@ class SyncEngine {
|
||||||
// thus, the entries are not in the dry-run DB copy, thus, at this point the client thinks that this is an item to upload
|
// thus, the entries are not in the dry-run DB copy, thus, at this point the client thinks that this is an item to upload
|
||||||
// Check this 'path' for an entry in pathFakeDeletedArray - if it is there, this is unwanted
|
// Check this 'path' for an entry in pathFakeDeletedArray - if it is there, this is unwanted
|
||||||
if (dryRun) {
|
if (dryRun) {
|
||||||
// Is this path in the array of fake deleted items?
|
// Is this path in the array of fake deleted items? If yes, return early, nothing else to do, save processing
|
||||||
unwanted = canFind(pathFakeDeletedArray, path);
|
if (canFind(pathFakeDeletedArray, path)) return;
|
||||||
// Return early, nothing else to do
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This not a Client Side Filtering check, nor a Microsoft Check, but is a sanity check that the path provided is UTF encoded correctly
|
// This not a Client Side Filtering check, nor a Microsoft Check, but is a sanity check that the path provided is UTF encoded correctly
|
||||||
|
@ -5473,8 +5471,12 @@ class SyncEngine {
|
||||||
Thread.sleep(dur!"seconds"(30));
|
Thread.sleep(dur!"seconds"(30));
|
||||||
}
|
}
|
||||||
// re-try original request - retried for 429, 503, 504 - but loop back calling this function
|
// re-try original request - retried for 429, 503, 504 - but loop back calling this function
|
||||||
log.vdebug("Retrying Query: generateDeltaResponseOneDriveApiInstance.listChildren(searchItem.driveId, searchItem.id, nextLink)");
|
//log.vdebug("Retrying Query: generateDeltaResponseOneDriveApiInstance.listChildren(searchItem.driveId, searchItem.id, nextLink)");
|
||||||
topLevelChildren = generateDeltaResponseOneDriveApiInstance.listChildren(searchItem.driveId, searchItem.id, nextLink);
|
//topLevelChildren = generateDeltaResponseOneDriveApiInstance.listChildren(searchItem.driveId, searchItem.id, nextLink);
|
||||||
|
|
||||||
|
log.vdebug("Retrying Function: ", thisFunctionName);
|
||||||
|
generateDeltaResponse(pathToQuery);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Default operation if not 408,429,503,504 errors
|
// Default operation if not 408,429,503,504 errors
|
||||||
// display what the error is
|
// display what the error is
|
||||||
|
@ -5633,49 +5635,73 @@ class SyncEngine {
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
// query children
|
// query children
|
||||||
thisLevelChildren = queryThisLevelChildren(driveId, idToQuery, nextLink);
|
|
||||||
|
|
||||||
// process this level children
|
try {
|
||||||
if (!childParentPath.empty) {
|
|
||||||
// We dont use childParentPath to log, as this poses an information leak risk.
|
thisLevelChildren = queryThisLevelChildren(driveId, idToQuery, nextLink);
|
||||||
// The full parent path of the child, as per the JSON might be:
|
|
||||||
// /Level 1/Level 2/Level 3/Child Shared Folder/some folder/another folder
|
} catch (OneDriveException exception) {
|
||||||
// But 'Child Shared Folder' is what is shared, thus '/Level 1/Level 2/Level 3/' is a potential information leak if logged.
|
|
||||||
// Plus, the application output now shows accuratly what is being shared - so that is a good thing.
|
|
||||||
log.vlog("Adding ", count(thisLevelChildren["value"].array), " OneDrive items for processing from ", pathForLogging);
|
writeln("EXCEPTION HANDLING NEEDED: thisLevelChildren = queryThisLevelChildren(driveId, idToQuery, nextLink)");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
foreach (child; thisLevelChildren["value"].array) {
|
|
||||||
// Check for any Client Side Filtering here ... we should skip querying the OneDrive API for 'folders' that we are going to just process and skip anyway.
|
// Was a valid JSON response for 'thisLevelChildren' provided?
|
||||||
// This avoids needless calls to the OneDrive API, and potentially speeds up this process.
|
if (thisLevelChildren.type() == JSONType.object) {
|
||||||
if (!checkJSONAgainstClientSideFiltering(child)) {
|
|
||||||
// add this child to the array of objects
|
// process this level children
|
||||||
thisLevelChildrenData ~= child;
|
if (!childParentPath.empty) {
|
||||||
// is this child a folder?
|
// We dont use childParentPath to log, as this poses an information leak risk.
|
||||||
if (isItemFolder(child)){
|
// The full parent path of the child, as per the JSON might be:
|
||||||
// We have to query this folders children if childCount > 0
|
// /Level 1/Level 2/Level 3/Child Shared Folder/some folder/another folder
|
||||||
if (child["folder"]["childCount"].integer > 0){
|
// But 'Child Shared Folder' is what is shared, thus '/Level 1/Level 2/Level 3/' is a potential information leak if logged.
|
||||||
// This child folder has children
|
// Plus, the application output now shows accuratly what is being shared - so that is a good thing.
|
||||||
string childIdToQuery = child["id"].str;
|
log.vlog("Adding ", count(thisLevelChildren["value"].array), " OneDrive items for processing from ", pathForLogging);
|
||||||
string childDriveToQuery = child["parentReference"]["driveId"].str;
|
}
|
||||||
auto grandchildParentPath = child["parentReference"]["path"].str.split(":");
|
foreach (child; thisLevelChildren["value"].array) {
|
||||||
string folderPathToScan = grandchildParentPath[1] ~ "/" ~ child["name"].str;
|
// Check for any Client Side Filtering here ... we should skip querying the OneDrive API for 'folders' that we are going to just process and skip anyway.
|
||||||
string newLoggingPath = pathForLogging ~ "/" ~ child["name"].str;
|
// This avoids needless calls to the OneDrive API, and potentially speeds up this process.
|
||||||
JSONValue[] grandChildrenData = queryForChildren(childDriveToQuery, childIdToQuery, folderPathToScan, newLoggingPath);
|
if (!checkJSONAgainstClientSideFiltering(child)) {
|
||||||
foreach (grandChild; grandChildrenData.array) {
|
// add this child to the array of objects
|
||||||
// add the grandchild to the array
|
thisLevelChildrenData ~= child;
|
||||||
thisLevelChildrenData ~= grandChild;
|
// is this child a folder?
|
||||||
|
if (isItemFolder(child)){
|
||||||
|
// We have to query this folders children if childCount > 0
|
||||||
|
if (child["folder"]["childCount"].integer > 0){
|
||||||
|
// This child folder has children
|
||||||
|
string childIdToQuery = child["id"].str;
|
||||||
|
string childDriveToQuery = child["parentReference"]["driveId"].str;
|
||||||
|
auto grandchildParentPath = child["parentReference"]["path"].str.split(":");
|
||||||
|
string folderPathToScan = grandchildParentPath[1] ~ "/" ~ child["name"].str;
|
||||||
|
string newLoggingPath = pathForLogging ~ "/" ~ child["name"].str;
|
||||||
|
JSONValue[] grandChildrenData = queryForChildren(childDriveToQuery, childIdToQuery, folderPathToScan, newLoggingPath);
|
||||||
|
foreach (grandChild; grandChildrenData.array) {
|
||||||
|
// add the grandchild to the array
|
||||||
|
thisLevelChildrenData ~= grandChild;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// If a collection exceeds the default page size (200 items), the @odata.nextLink property is returned in the response
|
||||||
|
// to indicate more items are available and provide the request URL for the next page of items.
|
||||||
|
if ("@odata.nextLink" in thisLevelChildren) {
|
||||||
|
// Update nextLink to next changeSet bundle
|
||||||
|
nextLink = thisLevelChildren["@odata.nextLink"].str;
|
||||||
|
log.vdebug("Setting nextLink to (@odata.nextLink): ", nextLink);
|
||||||
|
} else break;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// driveData is an invalid JSON object
|
||||||
|
writeln("CODING TO DO: The query of OneDrive API to thisLevelChildren = queryThisLevelChildren(driveId, idToQuery, nextLink) generated an invalid JSON response - thus we cant build our own /delta simulated response ... how to handle?");
|
||||||
|
// Must exit here
|
||||||
|
exit(-1);
|
||||||
}
|
}
|
||||||
// If a collection exceeds the default page size (200 items), the @odata.nextLink property is returned in the response
|
|
||||||
// to indicate more items are available and provide the request URL for the next page of items.
|
|
||||||
if ("@odata.nextLink" in thisLevelChildren) {
|
|
||||||
// Update nextLink to next changeSet bundle
|
|
||||||
nextLink = thisLevelChildren["@odata.nextLink"].str;
|
|
||||||
log.vdebug("Setting nextLink to (@odata.nextLink): ", nextLink);
|
|
||||||
} else break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// return response
|
// return response
|
||||||
|
@ -5735,8 +5761,11 @@ class SyncEngine {
|
||||||
Thread.sleep(dur!"seconds"(30));
|
Thread.sleep(dur!"seconds"(30));
|
||||||
}
|
}
|
||||||
// re-try original request - retried for 429, 503, 504 - but loop back calling this function
|
// re-try original request - retried for 429, 503, 504 - but loop back calling this function
|
||||||
log.vdebug("Retrying Query: thisLevelChildren = queryThisLevelChildren(driveId, idToQuery, nextLink)");
|
//log.vdebug("Retrying Query: thisLevelChildren = queryThisLevelChildren(driveId, idToQuery, nextLink)");
|
||||||
thisLevelChildren = queryThisLevelChildren(driveId, idToQuery, nextLink);
|
//thisLevelChildren = queryThisLevelChildren(driveId, idToQuery, nextLink);
|
||||||
|
log.vdebug("Retrying Function: ", thisFunctionName);
|
||||||
|
queryThisLevelChildren(driveId, idToQuery, nextLink);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Default operation if not 408,429,503,504 errors
|
// Default operation if not 408,429,503,504 errors
|
||||||
// display what the error is
|
// display what the error is
|
||||||
|
|
Loading…
Reference in a new issue