Skip to content

Commit

Permalink
Gracefully handle OneDrive account password change (#73)
Browse files Browse the repository at this point in the history
* Gracefully handle OneDrive account password change rather than crashing if authorization token is now invalid
  • Loading branch information
abraunegg committed Jul 15, 2018
1 parent a4e055f commit d0209d8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/main.d
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion src/onedrive.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit d0209d8

Please sign in to comment.