Gracefully handle OneDrive account password change (#73)

* Gracefully handle OneDrive account password change rather than crashing if authorization token is now invalid
This commit is contained in:
abraunegg 2018-07-16 09:58:36 +10:00 committed by GitHub
parent a4e055fdc3
commit d0209d8dbc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View file

@ -192,7 +192,17 @@ int main(string[] args)
// Initialise the sync engine
log.log("Initializing the Synchronization Engine ...");
auto sync = new SyncEngine(cfg, onedrive, itemdb, selectiveSync);
sync.init();
try {
sync.init();
} catch (OneDriveException e) {
if (e.httpStatusCode == 400 || e.httpStatusCode == 401) {
// Authorization is invalid
log.log("\nAuthorization token invalid, use --logout to authorize the client again\n");
onedrive.http.shutdown();
return EXIT_FAILURE;
}
}
// Do we need to validate the syncDir to check for the presence of a '.nosync' file
if (checkMount) {

View file

@ -294,7 +294,6 @@ final class OneDriveApi
if (e.httpStatusCode == 400 || e.httpStatusCode == 401) {
e.msg ~= "\nRefresh token invalid, use --logout to authorize the client again";
}
throw e;
}
}