mirror of
https://github.com/abraunegg/onedrive
synced 2024-05-02 06:02:53 +02:00
Resolve #132 - Couldn't resolve host name on handle
* By default the DNS timeout on HTTP.method is too short. If DNS resolution takes too long, a resolution error is thrown. Increase DNS timeout to 5 seconds. * Cleanup unittest - double declaration
This commit is contained in:
parent
dff245d29b
commit
034eccfaec
|
@ -53,6 +53,7 @@ final class OneDriveApi
|
|||
{
|
||||
this.cfg = cfg;
|
||||
http = HTTP();
|
||||
http.dnsTimeout = (dur!"seconds"(5));
|
||||
if (debugHttp) {
|
||||
http.verbose = true;
|
||||
.debugResponse = true;
|
||||
|
|
22
src/util.d
22
src/util.d
|
@ -106,9 +106,15 @@ Regex!char wild2regex(const(char)[] pattern)
|
|||
// returns true if the network connection is available
|
||||
bool testNetwork()
|
||||
{
|
||||
HTTP http = HTTP("https://login.microsoftonline.com");
|
||||
http.method = HTTP.Method.head;
|
||||
return http.perform(ThrowOnError.no) == 0;
|
||||
try {
|
||||
HTTP http = HTTP("https://login.microsoftonline.com");
|
||||
http.dnsTimeout = (dur!"seconds"(5));
|
||||
http.method = HTTP.Method.head;
|
||||
http.perform();
|
||||
return true;
|
||||
} catch (SocketException) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// calls globMatch for each string in pattern separated by '|'
|
||||
|
@ -122,13 +128,6 @@ bool multiGlobMatch(const(char)[] path, const(char)[] pattern)
|
|||
return false;
|
||||
}
|
||||
|
||||
unittest
|
||||
{
|
||||
assert(multiGlobMatch(".hidden", ".*"));
|
||||
assert(multiGlobMatch(".hidden", "file|.*"));
|
||||
assert(!multiGlobMatch("foo.bar", "foo|bar"));
|
||||
}
|
||||
|
||||
bool isValidName(string path)
|
||||
{
|
||||
// allow root item
|
||||
|
@ -156,6 +155,9 @@ bool isValidName(string path)
|
|||
|
||||
unittest
|
||||
{
|
||||
assert(multiGlobMatch(".hidden", ".*"));
|
||||
assert(multiGlobMatch(".hidden", "file|.*"));
|
||||
assert(!multiGlobMatch("foo.bar", "foo|bar"));
|
||||
// that should detect invalid file/directory name.
|
||||
assert(isValidName("."));
|
||||
assert(isValidName("./general.file"));
|
||||
|
|
Loading…
Reference in a new issue