Improve robustness

This commit is contained in:
Eelco Dolstra 2016-09-20 17:25:44 +02:00
parent 794e4ab475
commit f12d56b27b

View file

@ -98,7 +98,11 @@ struct CurlDownloader : public Downloader
{ {
assert(!done); assert(!done);
done = true; done = true;
failure(std::make_exception_ptr(e)); try {
throw e;
} catch (...) {
callFailure(failure);
}
} }
size_t writeCallback(void * contents, size_t size, size_t nmemb) size_t writeCallback(void * contents, size_t size, size_t nmemb)
@ -241,8 +245,8 @@ struct CurlDownloader : public Downloader
(httpStatus == 200 || httpStatus == 304 || httpStatus == 226 /* FTP */ || httpStatus == 0 /* other protocol */)) (httpStatus == 200 || httpStatus == 304 || httpStatus == 226 /* FTP */ || httpStatus == 0 /* other protocol */))
{ {
result.cached = httpStatus == 304; result.cached = httpStatus == 304;
success(result);
done = true; done = true;
callSuccess(success, failure, const_cast<const DownloadResult &>(result));
} else { } else {
Error err = Error err =
(httpStatus == 404 || code == CURLE_FILE_COULDNT_READ_FILE) ? NotFound : (httpStatus == 404 || code == CURLE_FILE_COULDNT_READ_FILE) ? NotFound :