mirror of
https://github.com/abraunegg/onedrive
synced 2024-05-03 06:23:16 +02:00
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:
parent
a4e055fdc3
commit
d0209d8dbc
12
src/main.d
12
src/main.d
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue