Update PR

* Update PR
This commit is contained in:
abraunegg 2023-08-28 16:56:16 +10:00
parent f28bf7ae75
commit 3f5a4fa29c
3 changed files with 18 additions and 6 deletions

View file

@ -532,12 +532,13 @@ int main(string[] cliArgs) {
// Do we perform a sync with OneDrive?
if (notificationReceived || (currentTime - lastCheckTime > checkOnlineInterval) || (monitorLoopFullCount == 0)) {
// Increment monitorLoopFullCount
monitorLoopFullCount++;
log.vdebug(loopStartOutputMessage);
log.vdebug("Loop Number: ", monitorLoopFullCount);
log.log("Starting a sync with Microsoft OneDrive");
SysTime startFunctionProcessingTime = Clock.currTime();
log.vdebug("Start Monitor Loop Time: ", startFunctionProcessingTime);
// Increment monitorLoopFullCount
monitorLoopFullCount++;
// Did the user specify --upload-only?
if (appConfig.getValueBool("upload_only")) {

View file

@ -284,13 +284,13 @@ class OneDriveApi {
} else {
// Try and read the value from the appConfig if it is set, rather than trying to read the value from disk
if (!appConfig.refreshToken.empty) {
log.vdebug("read token from appConfig");
refreshToken = appConfig.refreshToken;
authorised = true;
} else {
// Try and read the file from disk
try {
refreshToken = readText(appConfig.refreshTokenFilePath);
// is the refresh_token empty?
if (refreshToken.empty) {
log.error("refreshToken exists but is empty: ", appConfig.refreshTokenFilePath);
@ -298,6 +298,8 @@ class OneDriveApi {
} else {
// existing token not empty
authorised = true;
// update appConfig.refreshToken
appConfig.refreshToken = refreshToken;
}
} catch (FileException e) {
authorised = authorise();
@ -308,6 +310,11 @@ class OneDriveApi {
authorised = false;
}
}
if (refreshToken.empty) {
// PROBLEM
writeln("refreshToken is empty !!!!!!!!!! will cause 4xx errors");
}
}
// Return if we are authorised
log.vdebug("Authorised State: ", authorised);

View file

@ -1773,12 +1773,16 @@ class SyncEngine {
// Function variables
JSONValue deltaChangesBundle;
// Get the /delta data for this account | driveId | deltaLink combination
// Create a new API Instance for this thread and initialise it
OneDriveApi getDeltaQueryOneDriveApiInstance;
getDeltaQueryOneDriveApiInstance = new OneDriveApi(appConfig);
getDeltaQueryOneDriveApiInstance.initialise();
try {
deltaChangesBundle = oneDriveApiInstance.viewChangesByItemId(selectedDriveId, selectedItemId, providedDeltaLink);
deltaChangesBundle = getDeltaQueryOneDriveApiInstance.viewChangesByItemId(selectedDriveId, selectedItemId, providedDeltaLink);
} catch (OneDriveException exception) {
log.vdebug("deltaChangesBundle = oneDriveApiInstance.viewChangesByItemId() generated a OneDriveException");
// display error and exit
defaultUnhandledHTTPErrorCode(exception);
// display error message
displayOneDriveErrorMessage(exception.msg, getFunctionName!({}));
}
// If the JSON response is a correct JSON object, and has an 'id' we can set these details