mirror of
https://github.com/abraunegg/onedrive
synced 2024-05-17 21:26:41 +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;
|
this.cfg = cfg;
|
||||||
http = HTTP();
|
http = HTTP();
|
||||||
|
http.dnsTimeout = (dur!"seconds"(5));
|
||||||
if (debugHttp) {
|
if (debugHttp) {
|
||||||
http.verbose = true;
|
http.verbose = true;
|
||||||
.debugResponse = 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
|
// returns true if the network connection is available
|
||||||
bool testNetwork()
|
bool testNetwork()
|
||||||
{
|
{
|
||||||
HTTP http = HTTP("https://login.microsoftonline.com");
|
try {
|
||||||
http.method = HTTP.Method.head;
|
HTTP http = HTTP("https://login.microsoftonline.com");
|
||||||
return http.perform(ThrowOnError.no) == 0;
|
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 '|'
|
// calls globMatch for each string in pattern separated by '|'
|
||||||
|
@ -122,13 +128,6 @@ bool multiGlobMatch(const(char)[] path, const(char)[] pattern)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
unittest
|
|
||||||
{
|
|
||||||
assert(multiGlobMatch(".hidden", ".*"));
|
|
||||||
assert(multiGlobMatch(".hidden", "file|.*"));
|
|
||||||
assert(!multiGlobMatch("foo.bar", "foo|bar"));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isValidName(string path)
|
bool isValidName(string path)
|
||||||
{
|
{
|
||||||
// allow root item
|
// allow root item
|
||||||
|
@ -156,6 +155,9 @@ bool isValidName(string path)
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
|
assert(multiGlobMatch(".hidden", ".*"));
|
||||||
|
assert(multiGlobMatch(".hidden", "file|.*"));
|
||||||
|
assert(!multiGlobMatch("foo.bar", "foo|bar"));
|
||||||
// that should detect invalid file/directory name.
|
// that should detect invalid file/directory name.
|
||||||
assert(isValidName("."));
|
assert(isValidName("."));
|
||||||
assert(isValidName("./general.file"));
|
assert(isValidName("./general.file"));
|
||||||
|
|
Loading…
Reference in a new issue