mirror of
https://github.com/abraunegg/onedrive
synced 2024-05-20 14:46:35 +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.datetime, std.exception, std.file, std.json, std.path;
|
||||||
import std.stdio, std.string, std.uni, std.uri;
|
import std.stdio, std.string, std.uni, std.uri;
|
||||||
import config;
|
import config;
|
||||||
|
import core.stdc.stdlib;
|
||||||
static import log;
|
static import log;
|
||||||
shared bool debugResponse = false;
|
shared bool debugResponse = false;
|
||||||
|
|
||||||
|
@ -54,6 +55,7 @@ final class OneDriveApi
|
||||||
this.cfg = cfg;
|
this.cfg = cfg;
|
||||||
http = HTTP();
|
http = HTTP();
|
||||||
http.dnsTimeout = (dur!"seconds"(5));
|
http.dnsTimeout = (dur!"seconds"(5));
|
||||||
|
http.dataTimeout = (dur!"seconds"(3600));
|
||||||
if (debugHttp) {
|
if (debugHttp) {
|
||||||
http.verbose = true;
|
http.verbose = true;
|
||||||
.debugResponse = true;
|
.debugResponse = true;
|
||||||
|
@ -423,7 +425,15 @@ final class OneDriveApi
|
||||||
content ~= data;
|
content ~= data;
|
||||||
return data.length;
|
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;
|
JSONValue json;
|
||||||
try {
|
try {
|
||||||
json = content.parseJSON();
|
json = content.parseJSON();
|
||||||
|
|
Loading…
Reference in a new issue