Gracefully handle OneDrive account password change

* 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:52:10 +10:00
parent a4e055fdc3
commit e5d3d18618
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("\nAuthorisation 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;
}
}