Catch unhandled curl exception on operationTimeout being exceeded (#886)

* Catch unhandled curl exception on operationTimeout being exceeded
This commit is contained in:
abraunegg 2020-04-23 10:25:41 +10:00 committed by GitHub
parent 7f267a5a74
commit 628c58ad58
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -82,11 +82,11 @@ final class OneDriveApi
{
this.cfg = cfg;
http = HTTP();
// Curl Timeout Handling
// DNS lookup timeout
http.dnsTimeout = (dur!"seconds"(5));
// timeout for connecting
// Timeout for connecting
http.connectTimeout = (dur!"seconds"(10));
// Timeouts
// with the following settings we force
// - if there is no data flow for 5min, abort
// - if the download time for one item exceeds 1h, abort
@ -584,16 +584,26 @@ final class OneDriveApi
};
// Perform download & display progress bar
http.perform();
writeln();
// Reset onProgress to not display anything for next download
http.onProgress = delegate int(size_t dltotal, size_t dlnow, size_t ultotal, size_t ulnow)
{
return 0;
};
try {
// try and catch any curl error
http.perform();
writeln();
// Reset onProgress to not display anything for next download
http.onProgress = delegate int(size_t dltotal, size_t dlnow, size_t ultotal, size_t ulnow)
{
return 0;
};
} catch (CurlException e) {
displayOneDriveErrorMessage(e.msg);
}
} else {
// No progress bar
http.perform();
try {
// try and catch any curl error
http.perform();
} catch (CurlException e) {
displayOneDriveErrorMessage(e.msg);
}
}
// Check the HTTP response code