mirror of
https://github.com/abraunegg/onedrive
synced 2024-05-10 01:36:39 +02:00
* Gracefully handle a timeout when accessing the Microsoft OneDrive Service * Update HTTP connection handling for long running operations based on https://forum.dlang.org/post/k2vbk5$re7$1@digitalmars.com & https://github.com/dlang/phobos/pull/797
This commit is contained in:
parent
6b670df686
commit
91d8b7ab93
|
@ -2,6 +2,7 @@ import std.net.curl: CurlException, HTTP;
|
|||
import std.datetime, std.exception, std.file, std.json, std.path;
|
||||
import std.stdio, std.string, std.uni, std.uri;
|
||||
import config;
|
||||
import core.stdc.stdlib;
|
||||
static import log;
|
||||
shared bool debugResponse = false;
|
||||
|
||||
|
@ -54,6 +55,7 @@ final class OneDriveApi
|
|||
this.cfg = cfg;
|
||||
http = HTTP();
|
||||
http.dnsTimeout = (dur!"seconds"(5));
|
||||
http.dataTimeout = (dur!"seconds"(3600));
|
||||
if (debugHttp) {
|
||||
http.verbose = true;
|
||||
.debugResponse = true;
|
||||
|
@ -423,7 +425,15 @@ final class OneDriveApi
|
|||
content ~= data;
|
||||
return data.length;
|
||||
};
|
||||
http.perform();
|
||||
|
||||
try {
|
||||
http.perform();
|
||||
} catch (CurlException e) {
|
||||
// Potentially Timeout was reached on handle error
|
||||
log.error("\nAccess to the Microsoft OneDrive service timed out - Internet connectivity issue?\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
JSONValue json;
|
||||
try {
|
||||
json = content.parseJSON();
|
||||
|
|
Loading…
Reference in a new issue