diff options
-rw-r--r-- | src/libfetchers/tarball.cc | 2 | ||||
-rw-r--r-- | src/libstore/filetransfer.cc | 8 | ||||
-rw-r--r-- | src/libstore/filetransfer.hh | 9 | ||||
-rw-r--r-- | src/libstore/http-binary-cache-store.cc | 4 | ||||
-rw-r--r-- | src/nix/upgrade-nix.cc | 2 | ||||
-rw-r--r-- | tests/unit/libstore/filetransfer.cc | 6 |
6 files changed, 10 insertions, 21 deletions
diff --git a/src/libfetchers/tarball.cc b/src/libfetchers/tarball.cc index cda6b7acb..c903895e2 100644 --- a/src/libfetchers/tarball.cc +++ b/src/libfetchers/tarball.cc @@ -46,7 +46,7 @@ DownloadFileResult downloadFile( request.expectedETag = getStrAttr(cached->infoAttrs, "etag"); FileTransferResult res; try { - res = getFileTransfer()->download(request); + res = getFileTransfer()->transfer(request); } 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 156ab6f7a..065f38a0c 100644 --- a/src/libstore/filetransfer.cc +++ b/src/libstore/filetransfer.cc @@ -817,17 +817,11 @@ ref<FileTransfer> makeFileTransfer() return makeCurlFileTransfer(); } -FileTransferResult FileTransfer::download(const FileTransferRequest & request) +FileTransferResult FileTransfer::transfer(const FileTransferRequest & request) { return enqueueFileTransfer(request).get(); } -FileTransferResult FileTransfer::upload(const FileTransferRequest & request) -{ - /* Note: this method is the same as download, but helps in readability */ - return enqueueFileTransfer(request).get(); -} - template<typename... Args> FileTransferError::FileTransferError(FileTransfer::Error error, std::optional<std::string> response, const Args & ... args) : Error(args...), error(error), response(response) diff --git a/src/libstore/filetransfer.hh b/src/libstore/filetransfer.hh index 23105e245..5d739112b 100644 --- a/src/libstore/filetransfer.hh +++ b/src/libstore/filetransfer.hh @@ -99,14 +99,9 @@ struct FileTransfer virtual std::future<FileTransferResult> enqueueFileTransfer(const FileTransferRequest & request) = 0; /** - * Synchronously download a file. + * Synchronously transfer a file. */ - FileTransferResult download(const FileTransferRequest & request); - - /** - * Synchronously upload a file. - */ - FileTransferResult upload(const FileTransferRequest & request); + FileTransferResult transfer(const FileTransferRequest & request); /** * Download a file, writing its data to a sink. The sink will be diff --git a/src/libstore/http-binary-cache-store.cc b/src/libstore/http-binary-cache-store.cc index 9fafabe65..8cbb50ee9 100644 --- a/src/libstore/http-binary-cache-store.cc +++ b/src/libstore/http-binary-cache-store.cc @@ -115,7 +115,7 @@ protected: try { FileTransferRequest request(makeRequest(path)); request.head = true; - getFileTransfer()->download(request); + getFileTransfer()->transfer(request); return true; } catch (FileTransferError & e) { /* S3 buckets return 403 if a file doesn't exist and the @@ -135,7 +135,7 @@ protected: req.data = StreamToSourceAdapter(istream).drain(); req.mimeType = mimeType; try { - getFileTransfer()->upload(req); + getFileTransfer()->transfer(req); } catch (FileTransferError & e) { throw UploadToHTTP("while uploading to HTTP binary cache at '%s': %s", cacheUri, e.msg()); } diff --git a/src/nix/upgrade-nix.cc b/src/nix/upgrade-nix.cc index cbc28fdd7..c7f31f3fb 100644 --- a/src/nix/upgrade-nix.cc +++ b/src/nix/upgrade-nix.cc @@ -286,7 +286,7 @@ struct CmdUpgradeNix : MixDryRun, EvalCommand // FIXME: use nixos.org? auto req = FileTransferRequest(storePathsUrl); - auto res = getFileTransfer()->download(req); + auto res = getFileTransfer()->transfer(req); auto state = std::make_unique<EvalState>(SearchPath{}, store); auto v = state->allocValue(); diff --git a/tests/unit/libstore/filetransfer.cc b/tests/unit/libstore/filetransfer.cc index 0e5c0965e..b60963a46 100644 --- a/tests/unit/libstore/filetransfer.cc +++ b/tests/unit/libstore/filetransfer.cc @@ -155,7 +155,7 @@ TEST(FileTransfer, NOT_ON_DARWIN(reportsSetupErrors)) auto [port, srv] = serveHTTP("404 not found", "", [] { return ""; }); auto ft = makeFileTransfer(); ASSERT_THROW( - ft->download(FileTransferRequest(fmt("http://[::1]:%d/index", port))), + ft->transfer(FileTransferRequest(fmt("http://[::1]:%d/index", port))), FileTransferError); } @@ -168,7 +168,7 @@ TEST(FileTransfer, NOT_ON_DARWIN(reportsTransferError)) auto ft = makeFileTransfer(); FileTransferRequest req(fmt("http://[::1]:%d/index", port)); req.baseRetryTimeMs = 0; - ASSERT_THROW(ft->download(req), FileTransferError); + ASSERT_THROW(ft->transfer(req), FileTransferError); } TEST(FileTransfer, NOT_ON_DARWIN(handlesContentEncoding)) @@ -205,7 +205,7 @@ TEST(FileTransfer, usesIntermediateLinkHeaders) auto ft = makeFileTransfer(); FileTransferRequest req(fmt("http://[::1]:%d/first", port)); req.baseRetryTimeMs = 0; - auto result = ft->download(req); + auto result = ft->transfer(req); ASSERT_EQ(result.immutableUrl, "http://foo"); } |