mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 08:16:15 +02:00
Further improve upload messages
This commit is contained in:
parent
a936a19da3
commit
a2ec7a3bfd
2 changed files with 11 additions and 8 deletions
|
@ -307,8 +307,8 @@ struct CurlDownloader : public Downloader
|
||||||
if (effectiveUrlCStr)
|
if (effectiveUrlCStr)
|
||||||
result.effectiveUrl = effectiveUrlCStr;
|
result.effectiveUrl = effectiveUrlCStr;
|
||||||
|
|
||||||
debug(format("finished download of '%s'; curl status = %d, HTTP status = %d, body = %d bytes")
|
debug("finished %s of '%s'; curl status = %d, HTTP status = %d, body = %d bytes",
|
||||||
% request.uri % code % httpStatus % (result.data ? result.data->size() : 0));
|
request.verb(), request.uri, code, httpStatus, result.data ? result.data->size() : 0);
|
||||||
|
|
||||||
if (code == CURLE_WRITE_ERROR && result.etag == request.expectedETag) {
|
if (code == CURLE_WRITE_ERROR && result.etag == request.expectedETag) {
|
||||||
code = CURLE_OK;
|
code = CURLE_OK;
|
||||||
|
@ -373,20 +373,18 @@ struct CurlDownloader : public Downloader
|
||||||
|
|
||||||
attempt++;
|
attempt++;
|
||||||
|
|
||||||
auto verb = request.data ? "upload" : "download";
|
|
||||||
|
|
||||||
auto exc =
|
auto exc =
|
||||||
code == CURLE_ABORTED_BY_CALLBACK && _isInterrupted
|
code == CURLE_ABORTED_BY_CALLBACK && _isInterrupted
|
||||||
? DownloadError(Interrupted, fmt("%s of '%s' was interrupted", verb, request.uri))
|
? DownloadError(Interrupted, fmt("%s of '%s' was interrupted", request.verb(), request.uri))
|
||||||
: httpStatus != 0
|
: httpStatus != 0
|
||||||
? DownloadError(err,
|
? DownloadError(err,
|
||||||
fmt("unable to %s '%s': HTTP error %d",
|
fmt("unable to %s '%s': HTTP error %d",
|
||||||
verb, request.uri, httpStatus)
|
request.verb(), request.uri, httpStatus)
|
||||||
+ (code == CURLE_OK ? "" : fmt(" (curl error: %s)", curl_easy_strerror(code)))
|
+ (code == CURLE_OK ? "" : fmt(" (curl error: %s)", curl_easy_strerror(code)))
|
||||||
)
|
)
|
||||||
: DownloadError(err,
|
: DownloadError(err,
|
||||||
fmt("unable to %s '%s': %s (%d)",
|
fmt("unable to %s '%s': %s (%d)",
|
||||||
verb, request.uri, curl_easy_strerror(code), code));
|
request.verb(), request.uri, curl_easy_strerror(code), code));
|
||||||
|
|
||||||
/* If this is a transient error, then maybe retry the
|
/* If this is a transient error, then maybe retry the
|
||||||
download after a while. */
|
download after a while. */
|
||||||
|
@ -547,7 +545,7 @@ struct CurlDownloader : public Downloader
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto & item : incoming) {
|
for (auto & item : incoming) {
|
||||||
debug(format("starting download of %s") % item->request.uri);
|
debug("starting %s of %s", item->request.verb(), item->request.uri);
|
||||||
item->init();
|
item->init();
|
||||||
curl_multi_add_handle(curlm, item->req);
|
curl_multi_add_handle(curlm, item->req);
|
||||||
item->active = true;
|
item->active = true;
|
||||||
|
|
|
@ -25,6 +25,11 @@ struct DownloadRequest
|
||||||
|
|
||||||
DownloadRequest(const std::string & uri)
|
DownloadRequest(const std::string & uri)
|
||||||
: uri(uri), parentAct(getCurActivity()) { }
|
: uri(uri), parentAct(getCurActivity()) { }
|
||||||
|
|
||||||
|
std::string verb()
|
||||||
|
{
|
||||||
|
return data ? "upload" : "download";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DownloadResult
|
struct DownloadResult
|
||||||
|
|
Loading…
Reference in a new issue