diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2019-09-04 13:30:11 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2019-09-04 13:30:11 +0200 |
commit | e302ba0e65ba875b7bafd6265285e5f06384b617 (patch) | |
tree | fe52d8a58f8f9bb3f57b8aee5b06aee52937c714 /src/libstore/download.cc | |
parent | 2dbd69dbf4538d5b7947d192979ff4feab322c2e (diff) | |
parent | b774845af7a645b44bff69cf9f655c47fe4b9fb2 (diff) |
Merge remote-tracking branch 'origin/master' into flakes
Diffstat (limited to 'src/libstore/download.cc')
-rw-r--r-- | src/libstore/download.cc | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/libstore/download.cc b/src/libstore/download.cc index 3835727a0..a5165773a 100644 --- a/src/libstore/download.cc +++ b/src/libstore/download.cc @@ -77,13 +77,13 @@ struct CurlDownloader : public Downloader DownloadItem(CurlDownloader & downloader, const DownloadRequest & request, - Callback<DownloadResult> callback) + Callback<DownloadResult> && callback) : downloader(downloader) , request(request) , act(*logger, lvlTalkative, actDownload, fmt(request.data ? "uploading '%s'" : "downloading '%s'", request.uri), {request.uri}, request.parentAct) - , callback(callback) + , callback(std::move(callback)) , finalSink([this](const unsigned char * data, size_t len) { if (this->request.dataCallback) { writtenToSink += len; @@ -342,15 +342,9 @@ struct CurlDownloader : public Downloader (httpStatus == 200 || httpStatus == 201 || httpStatus == 204 || httpStatus == 206 || httpStatus == 304 || httpStatus == 226 /* FTP */ || httpStatus == 0 /* other protocol */)) { result.cached = httpStatus == 304; + act.progress(result.bodySize, result.bodySize); done = true; - - try { - act.progress(result.bodySize, result.bodySize); - callback(std::move(result)); - } catch (...) { - done = true; - callback.rethrow(); - } + callback(std::move(result)); } else { @@ -671,7 +665,7 @@ struct CurlDownloader : public Downloader return; } - enqueueItem(std::make_shared<DownloadItem>(*this, request, callback)); + enqueueItem(std::make_shared<DownloadItem>(*this, request, std::move(callback))); } }; |