From a8d6577bf0d8050580d6d15ddab7788544c1f67d Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Sat, 26 Oct 2024 17:53:48 +0200 Subject: [PATCH] libstore: HttpBinaryCacheStore::{makeRequest -> makeURI} it only sets the one field anyway (and the parent activity as a side effect that does not depend on the exact location of the constructor call). when FileTransferRequest goes away we would need this anyway. Change-Id: I35cf2ed3533239181449a62cf34cd282b395e5db --- src/libstore/http-binary-cache-store.cc | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/libstore/http-binary-cache-store.cc b/src/libstore/http-binary-cache-store.cc index c68faf552..ab8ad1399 100644 --- a/src/libstore/http-binary-cache-store.cc +++ b/src/libstore/http-binary-cache-store.cc @@ -114,7 +114,7 @@ protected: checkEnabled(); try { - FileTransferRequest request(makeRequest(path)); + FileTransferRequest request{makeURI(path)}; request.head = true; getFileTransfer()->transfer(request); return true; @@ -132,7 +132,7 @@ protected: std::shared_ptr> istream, const std::string & mimeType) override { - auto req = makeRequest(path); + FileTransferRequest req{makeURI(path)}; req.data = StreamToSourceAdapter(istream).drain(); req.mimeType = mimeType; try { @@ -142,19 +142,18 @@ protected: } } - FileTransferRequest makeRequest(const std::string & path) + std::string makeURI(const std::string & path) { - return FileTransferRequest( - path.starts_with("https://") || path.starts_with("http://") || path.starts_with("file://") + return path.starts_with("https://") || path.starts_with("http://") + || path.starts_with("file://") ? path - : cacheUri + "/" + path); - + : cacheUri + "/" + path; } box_ptr getFile(const std::string & path) override { checkEnabled(); - auto request(makeRequest(path)); + FileTransferRequest request{makeURI(path)}; try { return getFileTransfer()->download(std::move(request)); } catch (FileTransferError & e) { @@ -169,7 +168,7 @@ protected: { checkEnabled(); - auto request(makeRequest(path)); + FileTransferRequest request{makeURI(path)}; try { return std::move(getFileTransfer()->enqueueFileTransfer(request).get().data);