about summary refs log tree commit diff
path: root/src/libstore/download.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-09-03T10·51+0200
committerEelco Dolstra <edolstra@gmail.com>2019-09-03T11·45+0200
commit7348653ff4fc4e9b2dc24943aabdb57179b1c75a (patch)
treec730713ccb743b185578ee1b37462a7fc68b10b4 /src/libstore/download.cc
parent8c4ea7a4516c517a0dd37b446bf5c1a6b157064c (diff)
Ensure that Callback is called only once
Also, make Callback movable but uncopyable.
Diffstat (limited to 'src/libstore/download.cc')
-rw-r--r--src/libstore/download.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libstore/download.cc b/src/libstore/download.cc
index a7d059465b0e..cdf56e09d69a 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;
@@ -665,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)));
     }
 };