mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 08:16:15 +02:00
enqueueDownload -> enqueueDataTransfer
This commit is contained in:
parent
142ed7fe45
commit
2df2741ec6
3 changed files with 8 additions and 8 deletions
|
@ -641,7 +641,7 @@ struct CurlDownloader : public Downloader
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void enqueueDownload(const DataTransferRequest & request,
|
void enqueueDataTransfer(const DataTransferRequest & request,
|
||||||
Callback<DataTransferResult> callback) override
|
Callback<DataTransferResult> callback) override
|
||||||
{
|
{
|
||||||
/* Ugly hack to support s3:// URIs. */
|
/* Ugly hack to support s3:// URIs. */
|
||||||
|
@ -687,10 +687,10 @@ ref<Downloader> makeDownloader()
|
||||||
return make_ref<CurlDownloader>();
|
return make_ref<CurlDownloader>();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::future<DataTransferResult> Downloader::enqueueDownload(const DataTransferRequest & request)
|
std::future<DataTransferResult> Downloader::enqueueDataTransfer(const DataTransferRequest & request)
|
||||||
{
|
{
|
||||||
auto promise = std::make_shared<std::promise<DataTransferResult>>();
|
auto promise = std::make_shared<std::promise<DataTransferResult>>();
|
||||||
enqueueDownload(request,
|
enqueueDataTransfer(request,
|
||||||
{[promise](std::future<DataTransferResult> fut) {
|
{[promise](std::future<DataTransferResult> fut) {
|
||||||
try {
|
try {
|
||||||
promise->set_value(fut.get());
|
promise->set_value(fut.get());
|
||||||
|
@ -703,7 +703,7 @@ std::future<DataTransferResult> Downloader::enqueueDownload(const DataTransferRe
|
||||||
|
|
||||||
DataTransferResult Downloader::download(const DataTransferRequest & request)
|
DataTransferResult Downloader::download(const DataTransferRequest & request)
|
||||||
{
|
{
|
||||||
return enqueueDownload(request).get();
|
return enqueueDataTransfer(request).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Downloader::download(DataTransferRequest && request, Sink & sink)
|
void Downloader::download(DataTransferRequest && request, Sink & sink)
|
||||||
|
@ -755,7 +755,7 @@ void Downloader::download(DataTransferRequest && request, Sink & sink)
|
||||||
state->avail.notify_one();
|
state->avail.notify_one();
|
||||||
};
|
};
|
||||||
|
|
||||||
enqueueDownload(request,
|
enqueueDataTransfer(request,
|
||||||
{[_state](std::future<DataTransferResult> fut) {
|
{[_state](std::future<DataTransferResult> fut) {
|
||||||
auto state(_state->lock());
|
auto state(_state->lock());
|
||||||
state->quit = true;
|
state->quit = true;
|
||||||
|
|
|
@ -74,10 +74,10 @@ struct Downloader
|
||||||
/* Enqueue a download request, returning a future to the result of
|
/* Enqueue a download request, returning a future to the result of
|
||||||
the download. The future may throw a DownloadError
|
the download. The future may throw a DownloadError
|
||||||
exception. */
|
exception. */
|
||||||
virtual void enqueueDownload(const DataTransferRequest & request,
|
virtual void enqueueDataTransfer(const DataTransferRequest & request,
|
||||||
Callback<DataTransferResult> callback) = 0;
|
Callback<DataTransferResult> callback) = 0;
|
||||||
|
|
||||||
std::future<DataTransferResult> enqueueDownload(const DataTransferRequest & request);
|
std::future<DataTransferResult> enqueueDataTransfer(const DataTransferRequest & request);
|
||||||
|
|
||||||
/* Synchronously download a file. */
|
/* Synchronously download a file. */
|
||||||
DataTransferResult download(const DataTransferRequest & request);
|
DataTransferResult download(const DataTransferRequest & request);
|
||||||
|
|
|
@ -142,7 +142,7 @@ protected:
|
||||||
|
|
||||||
auto callbackPtr = std::make_shared<decltype(callback)>(std::move(callback));
|
auto callbackPtr = std::make_shared<decltype(callback)>(std::move(callback));
|
||||||
|
|
||||||
getDownloader()->enqueueDownload(request,
|
getDownloader()->enqueueDataTransfer(request,
|
||||||
{[callbackPtr, this](std::future<DataTransferResult> result) {
|
{[callbackPtr, this](std::future<DataTransferResult> result) {
|
||||||
try {
|
try {
|
||||||
(*callbackPtr)(result.get().data);
|
(*callbackPtr)(result.get().data);
|
||||||
|
|
Loading…
Reference in a new issue