From fdd478405acfc07d03b66a03f491f628e5ee6d7e Mon Sep 17 00:00:00 2001 From: abraunegg Date: Fri, 28 Jun 2019 05:15:39 +1000 Subject: [PATCH 1/7] Update fix for issue #555 * Update fix for #555 as try | catch block for session creation appears to miss error response codes --- src/upload.d | 83 +++++++++++++++++++++++++++++----------------------- 1 file changed, 47 insertions(+), 36 deletions(-) diff --git a/src/upload.d b/src/upload.d index d93a499e4..2c9e26144 100644 --- a/src/upload.d +++ b/src/upload.d @@ -143,6 +143,10 @@ struct UploadSession JSONValue upload() { + // Response for upload + JSONValue response; + + // session JSON needs to contain valid elements long offset; long fileSize; @@ -154,45 +158,52 @@ struct UploadSession fileSize = getSize(session["localPath"].str); } - // Upload Progress Bar - size_t iteration = (roundTo!int(double(fileSize)/double(fragmentSize)))+1; - Progress p = new Progress(iteration); - p.title = "Uploading"; - - JSONValue response; - while (true) { - p.next(); - long fragSize = fragmentSize < fileSize - offset ? fragmentSize : fileSize - offset; - // If the resume upload fails, we need to check for a return code here - try { - response = onedrive.uploadFragment( - session["uploadUrl"].str, - session["localPath"].str, - offset, - fragSize, - fileSize - ); - offset += fragmentSize; - if (offset >= fileSize) break; - // update the session details - session["expirationDateTime"] = response["expirationDateTime"]; - session["nextExpectedRanges"] = response["nextExpectedRanges"]; - save(); - } catch (OneDriveException e) { - // there was an error remove session file - if (exists(sessionFilePath)) { - remove(sessionFilePath); + if ("uploadUrl" in session){ + // Upload file via session created + // Upload Progress Bar + size_t iteration = (roundTo!int(double(fileSize)/double(fragmentSize)))+1; + Progress p = new Progress(iteration); + p.title = "Uploading"; + + while (true) { + p.next(); + long fragSize = fragmentSize < fileSize - offset ? fragmentSize : fileSize - offset; + // If the resume upload fails, we need to check for a return code here + try { + response = onedrive.uploadFragment( + session["uploadUrl"].str, + session["localPath"].str, + offset, + fragSize, + fileSize + ); + offset += fragmentSize; + if (offset >= fileSize) break; + // update the session details + session["expirationDateTime"] = response["expirationDateTime"]; + session["nextExpectedRanges"] = response["nextExpectedRanges"]; + save(); + } catch (OneDriveException e) { + // there was an error remove session file + if (exists(sessionFilePath)) { + remove(sessionFilePath); + } + return response; } - return response; } + // upload complete + p.next(); + writeln(); + if (exists(sessionFilePath)) { + remove(sessionFilePath); + } + return response; + } else { + // session elements were not present + log.vlog("Session has no valid upload URL ... skipping this file upload"); + // return an empty JSON response + return response; } - // upload complete - p.next(); - writeln(); - if (exists(sessionFilePath)) { - remove(sessionFilePath); - } - return response; } private void save() From 5979802c63c3c8c82378a9512d2c059bc9597d81 Mon Sep 17 00:00:00 2001 From: abraunegg Date: Fri, 28 Jun 2019 12:56:15 +1000 Subject: [PATCH 2/7] Update sync.d * Udate handling when response is not a valid JSON object --- src/sync.d | 107 +++++++++++++++++++++++++++-------------------------- 1 file changed, 55 insertions(+), 52 deletions(-) diff --git a/src/sync.d b/src/sync.d index 8cf0c18c8..7b51591bb 100644 --- a/src/sync.d +++ b/src/sync.d @@ -2055,64 +2055,67 @@ final class SyncEngine // Log action to log file log.fileOnly("Uploading new file ", path, " ... done."); - // The file was uploaded, or a 4xx / 5xx error was generated - if ("size" in response){ - // The response JSON contains size, high likelihood valid response returned - ulong uploadFileSize = response["size"].integer; - - // In some cases the file that was uploaded was not complete, but 'completed' without errors on OneDrive - // This has been seen with PNG / JPG files mainly, which then contributes to generating a 412 error when we attempt to update the metadata - // Validate here that the file uploaded, at least in size, matches in the response to what the size is on disk - if (thisFileSize != uploadFileSize){ - if(disableUploadValidation){ - // Print a warning message - log.log("WARNING: Uploaded file size does not match local file - skipping upload validation"); - } else { - // OK .. the uploaded file does not match and we did not disable this validation - log.log("Uploaded file size does not match local file - upload failure - retrying"); - // Delete uploaded bad file - onedrive.deleteById(response["parentReference"]["driveId"].str, response["id"].str, response["eTag"].str); - // Re-upload - uploadNewFile(path); - return; - } - } - - // File validation is OK - if ((accountType == "personal") || (thisFileSize == 0)){ - // Update the item's metadata on OneDrive - string id = response["id"].str; - string cTag; + // response from OneDrive has to be a valid JSON object + if (response.object()){ + // The file was uploaded, or a 4xx / 5xx error was generated + if ("size" in response){ + // The response JSON contains size, high likelihood valid response returned + ulong uploadFileSize = response["size"].integer; - // Is there a valid cTag in the response? - if ("cTag" in response) { - // use the cTag instead of the eTag because OneDrive may update the metadata of files AFTER they have been uploaded - cTag = response["cTag"].str; - } else { - // Is there an eTag in the response? - if ("eTag" in response) { - // use the eTag from the response as there was no cTag - cTag = response["eTag"].str; + // In some cases the file that was uploaded was not complete, but 'completed' without errors on OneDrive + // This has been seen with PNG / JPG files mainly, which then contributes to generating a 412 error when we attempt to update the metadata + // Validate here that the file uploaded, at least in size, matches in the response to what the size is on disk + if (thisFileSize != uploadFileSize){ + if(disableUploadValidation){ + // Print a warning message + log.log("WARNING: Uploaded file size does not match local file - skipping upload validation"); } else { - // no tag available - set to nothing - cTag = ""; + // OK .. the uploaded file does not match and we did not disable this validation + log.log("Uploaded file size does not match local file - upload failure - retrying"); + // Delete uploaded bad file + onedrive.deleteById(response["parentReference"]["driveId"].str, response["id"].str, response["eTag"].str); + // Re-upload + uploadNewFile(path); + return; } - } + } - if (exists(path)) { - SysTime mtime = timeLastModified(path).toUTC(); - uploadLastModifiedTime(parent.driveId, id, cTag, mtime); + // File validation is OK + if ((accountType == "personal") || (thisFileSize == 0)){ + // Update the item's metadata on OneDrive + string id = response["id"].str; + string cTag; + + // Is there a valid cTag in the response? + if ("cTag" in response) { + // use the cTag instead of the eTag because OneDrive may update the metadata of files AFTER they have been uploaded + cTag = response["cTag"].str; + } else { + // Is there an eTag in the response? + if ("eTag" in response) { + // use the eTag from the response as there was no cTag + cTag = response["eTag"].str; + } else { + // no tag available - set to nothing + cTag = ""; + } + } + + if (exists(path)) { + SysTime mtime = timeLastModified(path).toUTC(); + uploadLastModifiedTime(parent.driveId, id, cTag, mtime); + } else { + // will be removed in different event! + log.log("File disappeared after upload: ", path); + } + return; } else { - // will be removed in different event! - log.log("File disappeared after upload: ", path); + // OneDrive Business Account - always use a session to upload + // The session includes a Request Body element containing lastModifiedDateTime + // which negates the need for a modify event against OneDrive + saveItem(response); + return; } - return; - } else { - // OneDrive Business Account - always use a session to upload - // The session includes a Request Body element containing lastModifiedDateTime - // which negates the need for a modify event against OneDrive - saveItem(response); - return; } } } else { From 7cf73a21f213d6cfae6ae665cfb926f91dfb1239 Mon Sep 17 00:00:00 2001 From: abraunegg Date: Fri, 28 Jun 2019 17:38:38 +1000 Subject: [PATCH 3/7] remove try block * remove try block and trap for explicit entry earlier --- src/sync.d | 8 ++++++-- src/upload.d | 9 +++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/sync.d b/src/sync.d index 4282cb5b9..311230852 100644 --- a/src/sync.d +++ b/src/sync.d @@ -2058,7 +2058,6 @@ final class SyncEngine writeln(""); try { response = session.upload(path, parent.driveId, parent.id, baseName(path)); - writeln(" done."); } catch (OneDriveException e) { // error uploading file log.vlog("Upload failed with OneDriveException: ", e.msg); @@ -2067,17 +2066,22 @@ final class SyncEngine log.vlog("Upload failed with File Exception: ", e.msg); return; } + writeln(" done."); } } else { // OneDrive Business Account - always use a session to upload writeln(""); try { response = session.upload(path, parent.driveId, parent.id, baseName(path)); - writeln(" done."); } catch (OneDriveException e) { // error uploading file + log.vlog("Upload failed with OneDriveException: ", e.msg); + return; + } catch (FileException e) { + log.vlog("Upload failed with File Exception: ", e.msg); return; } + writeln(" done."); } } diff --git a/src/upload.d b/src/upload.d index 2c9e26144..d01873405 100644 --- a/src/upload.d +++ b/src/upload.d @@ -39,13 +39,14 @@ struct UploadSession ]) ]; - try { - // Try to create the upload session for this file - session = onedrive.createUploadSession(parentDriveId, parentId, filename, eTag, fileSystemInfo); + // Try to create the upload session for this file + session = onedrive.createUploadSession(parentDriveId, parentId, filename, eTag, fileSystemInfo); + + if ("uploadUrl" in session){ session["localPath"] = localPath; save(); return upload(); - } catch (OneDriveException e) { + } else { // there was an error log.vlog("Create file upload session failed ... skipping file upload"); // return upload() will return a JSONValue response, create an empty JSONValue response to return From f64091ba17592f412446a17bea2897471d6e2bfb Mon Sep 17 00:00:00 2001 From: abraunegg Date: Sat, 29 Jun 2019 13:03:08 +1000 Subject: [PATCH 4/7] Update how JSONValue object is determined to be valid * Update how JSONValue object is determined to be valid --- src/sync.d | 95 ++++++++++++++++++++++++++++------------------------ src/upload.d | 2 +- 2 files changed, 53 insertions(+), 44 deletions(-) diff --git a/src/sync.d b/src/sync.d index 311230852..70f5c616c 100644 --- a/src/sync.d +++ b/src/sync.d @@ -307,48 +307,57 @@ final class SyncEngine } } - if ((hasId(oneDriveDetails)) && (hasId(oneDriveRootDetails))) { - // JSON elements are valid - // Debug OneDrive Account details response - log.vdebug("OneDrive Account Details: ", oneDriveDetails); - log.vdebug("OneDrive Account Root Details: ", oneDriveRootDetails); + if ((oneDriveDetails.type() == JSONType.object) && (oneDriveRootDetails.type() == JSONType.object)) { + if ((hasId(oneDriveDetails)) && (hasId(oneDriveRootDetails))) { + // JSON elements are valid + // Debug OneDrive Account details response + log.vdebug("OneDrive Account Details: ", oneDriveDetails); + log.vdebug("OneDrive Account Root Details: ", oneDriveRootDetails); + + // Successfully got details from OneDrive without a server side error such as 'HTTP/1.1 500 Internal Server Error' or 'HTTP/1.1 504 Gateway Timeout' + accountType = oneDriveDetails["driveType"].str; + defaultDriveId = oneDriveDetails["id"].str; + defaultRootId = oneDriveRootDetails["id"].str; + remainingFreeSpace = oneDriveDetails["quota"]["remaining"].integer; + + // In some cases OneDrive Business configurations 'restrict' quota details thus is empty / blank / negative value / zero + if (remainingFreeSpace <= 0) { + // quota details not available + log.error("ERROR: OneDrive quota information is being restricted. Please fix by speaking to your OneDrive / Office 365 Administrator."); + log.error("ERROR: Flagging to disable upload space checks - this MAY have undesirable results if a file cannot be uploaded due to out of space."); + quotaAvailable = false; + } + + // Display accountType, defaultDriveId, defaultRootId & remainingFreeSpace for verbose logging purposes + log.vlog("Account Type: ", accountType); + log.vlog("Default Drive ID: ", defaultDriveId); + log.vlog("Default Root ID: ", defaultRootId); + log.vlog("Remaining Free Space: ", remainingFreeSpace); - // Successfully got details from OneDrive without a server side error such as 'HTTP/1.1 500 Internal Server Error' or 'HTTP/1.1 504 Gateway Timeout' - accountType = oneDriveDetails["driveType"].str; - defaultDriveId = oneDriveDetails["id"].str; - defaultRootId = oneDriveRootDetails["id"].str; - remainingFreeSpace = oneDriveDetails["quota"]["remaining"].integer; + // If account type is documentLibrary - then most likely this is a SharePoint repository + // and files 'may' be modified after upload. See: /~https://github.com/abraunegg/onedrive/issues/205 + if(accountType == "documentLibrary") { + setDisableUploadValidation(); + } - // In some cases OneDrive Business configurations 'restrict' quota details thus is empty / blank / negative value / zero - if (remainingFreeSpace <= 0) { - // quota details not available - log.error("ERROR: OneDrive quota information is being restricted. Please fix by speaking to your OneDrive / Office 365 Administrator."); - log.error("ERROR: Flagging to disable upload space checks - this MAY have undesirable results if a file cannot be uploaded due to out of space."); - quotaAvailable = false; - } + // Check the local database to ensure the OneDrive Root details are in the database + checkDatabaseForOneDriveRoot(); - // Display accountType, defaultDriveId, defaultRootId & remainingFreeSpace for verbose logging purposes - log.vlog("Account Type: ", accountType); - log.vlog("Default Drive ID: ", defaultDriveId); - log.vlog("Default Root ID: ", defaultRootId); - log.vlog("Remaining Free Space: ", remainingFreeSpace); - - // If account type is documentLibrary - then most likely this is a SharePoint repository - // and files 'may' be modified after upload. See: /~https://github.com/abraunegg/onedrive/issues/205 - if(accountType == "documentLibrary") { - setDisableUploadValidation(); + // Check if there is an interrupted upload session + if (session.restore()) { + log.log("Continuing the upload session ..."); + auto item = session.upload(); + saveItem(item); + } + initDone = true; + } else { + // init failure + initDone = false; + // log why + log.error("ERROR: Unable to query OneDrive to initialize application"); + // Must exit here + exit(-1); } - - // Check the local database to ensure the OneDrive Root details are in the database - checkDatabaseForOneDriveRoot(); - - // Check if there is an interrupted upload session - if (session.restore()) { - log.log("Continuing the upload session ..."); - auto item = session.upload(); - saveItem(item); - } - initDone = true; } else { // init failure initDone = false; @@ -1120,7 +1129,7 @@ final class SyncEngine } // fileDetails has to be a valid JSON object - if (fileDetails.object()){ + if (fileDetails.type() == JSONType.object){ if (isMalware(fileDetails)){ // OneDrive reports that this file is malware log.error("ERROR: MALWARE DETECTED IN FILE - DOWNLOAD SKIPPED"); @@ -1138,7 +1147,7 @@ final class SyncEngine if (!dryRun) { ulong fileSize = 0; string OneDriveFileHash; - if ( (hasFileSize(fileDetails)) && (hasQuickXorHash(fileDetails)) && (fileDetails.object()) ) { + if ( (hasFileSize(fileDetails)) && (hasQuickXorHash(fileDetails)) && (fileDetails.type() == JSONType.object) ) { // fileDetails is a valid JSON object with the elements we need // Set the file size from the returned data fileSize = fileDetails["size"].integer; @@ -2089,7 +2098,7 @@ final class SyncEngine log.fileOnly("Uploading new file ", path, " ... done."); // response from OneDrive has to be a valid JSON object - if (response.object()){ + if (response.type() == JSONType.object){ // The file was uploaded, or a 4xx / 5xx error was generated if ("size" in response){ // The response JSON contains size, high likelihood valid response returned @@ -2175,7 +2184,7 @@ final class SyncEngine // Note that NTFS supports POSIX semantics for case sensitivity but this is not the default behavior. // fileDetailsFromOneDrive has to be a valid object - if (fileDetailsFromOneDrive.object()){ + if (fileDetailsFromOneDrive.type() == JSONType.object){ // Check that 'name' is in the JSON response (validates data) and that 'name' == the path we are looking for if (("name" in fileDetailsFromOneDrive) && (fileDetailsFromOneDrive["name"].str == baseName(path))) { // OneDrive 'name' matches local path name @@ -2384,7 +2393,7 @@ final class SyncEngine private void saveItem(JSONValue jsonItem) { // jsonItem has to be a valid object - if (jsonItem.object()){ + if (jsonItem.type() == JSONType.object){ // Check if the response JSON has an 'id', otherwise makeItem() fails with 'Key not found: id' if (hasId(jsonItem)) { // Takes a JSON input and formats to an item which can be used by the database diff --git a/src/upload.d b/src/upload.d index d01873405..a2a67d646 100644 --- a/src/upload.d +++ b/src/upload.d @@ -95,7 +95,7 @@ struct UploadSession } // do we have a valid response from OneDrive? - if (response.object()){ + if (response.type() == JSONType.object){ // JSON object if (("expirationDateTime" in response) && ("nextExpectedRanges" in response)){ // has the elements we need From 076c547a41da49607348efa9848e858795053af1 Mon Sep 17 00:00:00 2001 From: abraunegg Date: Sat, 29 Jun 2019 13:22:17 +1000 Subject: [PATCH 5/7] Update sync.d * Add error logging when response is not a valid JSON object --- src/sync.d | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/sync.d b/src/sync.d index 70f5c616c..8d84e30ea 100644 --- a/src/sync.d +++ b/src/sync.d @@ -2159,6 +2159,11 @@ final class SyncEngine return; } } + } else { + // response is not valid JSON, an error was returned from OneDrive + log.error("ERROR: An error was returned from OneDrive and the resulting response is not a valid JSON object"); + log.error("ERROR: Increase logging verbosity to assist determining why."); + return; } } else { // we are --dry-run - simulate the file upload From e580aaa05d601071ccd04793f1b615576bf7d2ea Mon Sep 17 00:00:00 2001 From: abraunegg Date: Sat, 29 Jun 2019 14:11:40 +1000 Subject: [PATCH 6/7] Update sync.d * Clean-up messaging and error logging --- src/sync.d | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/sync.d b/src/sync.d index 8d84e30ea..f6121ffa0 100644 --- a/src/sync.d +++ b/src/sync.d @@ -2032,12 +2032,10 @@ final class SyncEngine // /~https://github.com/OneDrive/onedrive-api-docs/issues/53 try { response = onedrive.simpleUpload(path, parent.driveId, parent.id, baseName(path)); - writeln(" done."); } catch (OneDriveException e) { // error uploading file return; } - } else { // File is not a zero byte file // Are we using OneDrive Personal or OneDrive Business? @@ -2061,7 +2059,6 @@ final class SyncEngine } else throw e; } - writeln(" done."); } else { // File larger than threshold - use a session to upload writeln(""); @@ -2075,7 +2072,6 @@ final class SyncEngine log.vlog("Upload failed with File Exception: ", e.msg); return; } - writeln(" done."); } } else { // OneDrive Business Account - always use a session to upload @@ -2090,15 +2086,14 @@ final class SyncEngine log.vlog("Upload failed with File Exception: ", e.msg); return; } - writeln(" done."); } } - // Log action to log file - log.fileOnly("Uploading new file ", path, " ... done."); - // response from OneDrive has to be a valid JSON object if (response.type() == JSONType.object){ + // Log action to log file + log.fileOnly("Uploading new file ", path, " ... done."); + writeln(" done."); // The file was uploaded, or a 4xx / 5xx error was generated if ("size" in response){ // The response JSON contains size, high likelihood valid response returned @@ -2161,8 +2156,8 @@ final class SyncEngine } } else { // response is not valid JSON, an error was returned from OneDrive - log.error("ERROR: An error was returned from OneDrive and the resulting response is not a valid JSON object"); - log.error("ERROR: Increase logging verbosity to assist determining why."); + log.fileOnly("Uploading new file ", path, " ... error"); + writeln(" error"); return; } } else { From 7a81d4ecdce602c1bf3d19f4e6b4020e3a4941f7 Mon Sep 17 00:00:00 2001 From: abraunegg Date: Sun, 30 Jun 2019 08:43:05 +1000 Subject: [PATCH 7/7] Update sync.d * Simplify check to one statement --- src/sync.d | 87 ++++++++++++++++++++++++------------------------------ 1 file changed, 39 insertions(+), 48 deletions(-) diff --git a/src/sync.d b/src/sync.d index f6121ffa0..2620d842c 100644 --- a/src/sync.d +++ b/src/sync.d @@ -306,58 +306,49 @@ final class SyncEngine exit(-1); } } - - if ((oneDriveDetails.type() == JSONType.object) && (oneDriveRootDetails.type() == JSONType.object)) { - if ((hasId(oneDriveDetails)) && (hasId(oneDriveRootDetails))) { - // JSON elements are valid - // Debug OneDrive Account details response - log.vdebug("OneDrive Account Details: ", oneDriveDetails); - log.vdebug("OneDrive Account Root Details: ", oneDriveRootDetails); - - // Successfully got details from OneDrive without a server side error such as 'HTTP/1.1 500 Internal Server Error' or 'HTTP/1.1 504 Gateway Timeout' - accountType = oneDriveDetails["driveType"].str; - defaultDriveId = oneDriveDetails["id"].str; - defaultRootId = oneDriveRootDetails["id"].str; - remainingFreeSpace = oneDriveDetails["quota"]["remaining"].integer; - - // In some cases OneDrive Business configurations 'restrict' quota details thus is empty / blank / negative value / zero - if (remainingFreeSpace <= 0) { - // quota details not available - log.error("ERROR: OneDrive quota information is being restricted. Please fix by speaking to your OneDrive / Office 365 Administrator."); - log.error("ERROR: Flagging to disable upload space checks - this MAY have undesirable results if a file cannot be uploaded due to out of space."); - quotaAvailable = false; - } - - // Display accountType, defaultDriveId, defaultRootId & remainingFreeSpace for verbose logging purposes - log.vlog("Account Type: ", accountType); - log.vlog("Default Drive ID: ", defaultDriveId); - log.vlog("Default Root ID: ", defaultRootId); - log.vlog("Remaining Free Space: ", remainingFreeSpace); + + if ((oneDriveDetails.type() == JSONType.object) && (oneDriveRootDetails.type() == JSONType.object) && (hasId(oneDriveDetails)) && (hasId(oneDriveRootDetails))) { + // JSON elements are valid + // Debug OneDrive Account details response + log.vdebug("OneDrive Account Details: ", oneDriveDetails); + log.vdebug("OneDrive Account Root Details: ", oneDriveRootDetails); - // If account type is documentLibrary - then most likely this is a SharePoint repository - // and files 'may' be modified after upload. See: /~https://github.com/abraunegg/onedrive/issues/205 - if(accountType == "documentLibrary") { - setDisableUploadValidation(); - } + // Successfully got details from OneDrive without a server side error such as 'HTTP/1.1 500 Internal Server Error' or 'HTTP/1.1 504 Gateway Timeout' + accountType = oneDriveDetails["driveType"].str; + defaultDriveId = oneDriveDetails["id"].str; + defaultRootId = oneDriveRootDetails["id"].str; + remainingFreeSpace = oneDriveDetails["quota"]["remaining"].integer; - // Check the local database to ensure the OneDrive Root details are in the database - checkDatabaseForOneDriveRoot(); + // In some cases OneDrive Business configurations 'restrict' quota details thus is empty / blank / negative value / zero + if (remainingFreeSpace <= 0) { + // quota details not available + log.error("ERROR: OneDrive quota information is being restricted. Please fix by speaking to your OneDrive / Office 365 Administrator."); + log.error("ERROR: Flagging to disable upload space checks - this MAY have undesirable results if a file cannot be uploaded due to out of space."); + quotaAvailable = false; + } - // Check if there is an interrupted upload session - if (session.restore()) { - log.log("Continuing the upload session ..."); - auto item = session.upload(); - saveItem(item); - } - initDone = true; - } else { - // init failure - initDone = false; - // log why - log.error("ERROR: Unable to query OneDrive to initialize application"); - // Must exit here - exit(-1); + // Display accountType, defaultDriveId, defaultRootId & remainingFreeSpace for verbose logging purposes + log.vlog("Account Type: ", accountType); + log.vlog("Default Drive ID: ", defaultDriveId); + log.vlog("Default Root ID: ", defaultRootId); + log.vlog("Remaining Free Space: ", remainingFreeSpace); + + // If account type is documentLibrary - then most likely this is a SharePoint repository + // and files 'may' be modified after upload. See: /~https://github.com/abraunegg/onedrive/issues/205 + if(accountType == "documentLibrary") { + setDisableUploadValidation(); } + + // Check the local database to ensure the OneDrive Root details are in the database + checkDatabaseForOneDriveRoot(); + + // Check if there is an interrupted upload session + if (session.restore()) { + log.log("Continuing the upload session ..."); + auto item = session.upload(); + saveItem(item); + } + initDone = true; } else { // init failure initDone = false;