diff --git a/src/libfetchers/tarball.cc b/src/libfetchers/tarball.cc index e7e934b2a..bf8bbedd1 100644 --- a/src/libfetchers/tarball.cc +++ b/src/libfetchers/tarball.cc @@ -45,7 +45,9 @@ DownloadFileResult downloadFile( FileTransferResult res; std::string data; try { - std::tie(res, data) = getFileTransfer()->enqueueDownload(url, headers).get(); + auto [meta, content] = getFileTransfer()->download(url, headers); + res = std::move(meta); + data = content->drain(); } catch (FileTransferError & e) { if (cached) { warn("%s; using cached version", e.msg()); diff --git a/src/libstore/filetransfer.cc b/src/libstore/filetransfer.cc index 1f6c3e22b..03b3a045b 100644 --- a/src/libstore/filetransfer.cc +++ b/src/libstore/filetransfer.cc @@ -700,12 +700,6 @@ struct curlFileTransfer : public FileTransfer } #endif - std::future> - enqueueDownload(const std::string & uri, const Headers & headers = {}) override - { - return enqueueFileTransfer(uri, headers, std::nullopt, false); - } - void upload(const std::string & uri, std::string data, const Headers & headers) override { enqueueFileTransfer(uri, headers, std::move(data), false).get(); diff --git a/src/libstore/filetransfer.hh b/src/libstore/filetransfer.hh index 1abc07c4d..1cdd1af42 100644 --- a/src/libstore/filetransfer.hh +++ b/src/libstore/filetransfer.hh @@ -69,13 +69,6 @@ struct FileTransfer { virtual ~FileTransfer() { } - /** - * Enqueues a download request, returning a future for the result of - * the download. The future may throw a FileTransferError exception. - */ - virtual std::future> - enqueueDownload(const std::string & uri, const Headers & headers = {}) = 0; - /** * Upload some data. May throw a FileTransferError exception. */ diff --git a/src/libstore/http-binary-cache-store.cc b/src/libstore/http-binary-cache-store.cc index 9e81cd156..778892943 100644 --- a/src/libstore/http-binary-cache-store.cc +++ b/src/libstore/http-binary-cache-store.cc @@ -161,7 +161,7 @@ protected: checkEnabled(); try { - return std::move(getFileTransfer()->enqueueDownload(makeURI(path)).get().second); + return getFileTransfer()->download(makeURI(path)).second->drain(); } catch (FileTransferError & e) { if (e.error == FileTransfer::NotFound || e.error == FileTransfer::Forbidden) return {}; diff --git a/src/nix/upgrade-nix.cc b/src/nix/upgrade-nix.cc index c6cc74672..cb5eb2221 100644 --- a/src/nix/upgrade-nix.cc +++ b/src/nix/upgrade-nix.cc @@ -285,7 +285,8 @@ struct CmdUpgradeNix : MixDryRun, EvalCommand Activity act(*logger, lvlInfo, actUnknown, "querying latest Nix version"); // FIXME: use nixos.org? - auto [res, data] = getFileTransfer()->enqueueDownload(storePathsUrl).get(); + auto [res, content] = getFileTransfer()->download(storePathsUrl); + auto data = content->drain(); auto state = std::make_unique(SearchPath{}, store); auto v = state->allocValue(); diff --git a/tests/unit/libstore/filetransfer.cc b/tests/unit/libstore/filetransfer.cc index dd0c33f06..5885a8059 100644 --- a/tests/unit/libstore/filetransfer.cc +++ b/tests/unit/libstore/filetransfer.cc @@ -163,7 +163,7 @@ TEST(FileTransfer, NOT_ON_DARWIN(reportsSetupErrors)) auto [port, srv] = serveHTTP("404 not found", "", [] { return ""; }); auto ft = makeFileTransfer(); ASSERT_THROW( - ft->enqueueDownload(fmt("http://[::1]:%d/index", port)).get(), + ft->download(fmt("http://[::1]:%d/index", port)), FileTransferError ); } @@ -215,7 +215,7 @@ TEST(FileTransfer, usesIntermediateLinkHeaders) {"200 ok", "content-length: 1\r\n", [] { return "a"; }}, }); auto ft = makeFileTransfer(0); - auto [result, _data] = ft->enqueueDownload(fmt("http://[::1]:%d/first", port)).get(); + auto [result, _data] = ft->download(fmt("http://[::1]:%d/first", port)); ASSERT_EQ(result.immutableUrl, "http://foo"); }