Fix handling of UNC file URLs

- Qt thinks UNC URLs should look like: file://1.2.3.4/share/file.img
libcurl likes them: file:////1.2.3.4/share/file.img

So correct that.

- Mention it is an unspecified libcurl error if libcurl passes us
an error code with an empty error message string.

Closes #65
This commit is contained in:
Floris Bos 2020-05-24 00:00:35 +02:00
parent 3248f9f04b
commit 71eefa47cf

View file

@ -266,6 +266,14 @@ void DownloadThread::run()
return; return;
} }
qDebug() << "Image URL:" << _url;
if (_url.startsWith("file://") && _url.at(7) != '/')
{
/* libcurl does not like UNC paths in the form of file://1.2.3.4/share */
_url.replace("file://", "file:////");
qDebug() << "Corrected UNC URL to:" << _url;
}
char errorBuf[CURL_ERROR_SIZE] = {0}; char errorBuf[CURL_ERROR_SIZE] = {0};
_c = curl_easy_init(); _c = curl_easy_init();
curl_easy_setopt(_c, CURLOPT_NOSIGNAL, 1); curl_easy_setopt(_c, CURLOPT_NOSIGNAL, 1);
@ -332,7 +340,10 @@ void DownloadThread::run()
break; break;
default: default:
deleteDownloadedFile(); deleteDownloadedFile();
_onDownloadError(errorBuf); if (!errorBuf[0])
_onDownloadError("Unspecified libcurl error");
else
_onDownloadError(errorBuf);
} }
} }