From 5cd7055044d17af68d8cafb18da8b91e2e84b92b Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Sun, 27 Oct 2024 18:27:11 +0100 Subject: [PATCH] libstore: de-future-ize FileTransfer::enqueueUpload it's only used once, and synchronously at that. Change-Id: Ife9db15dd97bc0de8de59a25d27f3f7afeb8791b --- src/libstore/filetransfer.cc | 5 ++--- src/libstore/filetransfer.hh | 4 ++-- src/libstore/http-binary-cache-store.cc | 4 +--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/libstore/filetransfer.cc b/src/libstore/filetransfer.cc index 5a606b207..b68c636fa 100644 --- a/src/libstore/filetransfer.cc +++ b/src/libstore/filetransfer.cc @@ -663,10 +663,9 @@ struct curlFileTransfer : public FileTransfer return enqueueFileTransfer(uri, headers, std::nullopt, false); } - std::future - enqueueUpload(const std::string & uri, std::string data, const Headers & headers) override + void upload(const std::string & uri, std::string data, const Headers & headers) override { - return enqueueFileTransfer(uri, headers, std::move(data), false); + enqueueFileTransfer(uri, headers, std::move(data), false).get(); } std::future enqueueFileTransfer( diff --git a/src/libstore/filetransfer.hh b/src/libstore/filetransfer.hh index b885c59d5..2900fdee5 100644 --- a/src/libstore/filetransfer.hh +++ b/src/libstore/filetransfer.hh @@ -80,8 +80,8 @@ struct FileTransfer /** * Upload some data. May throw a FileTransferError exception. */ - virtual std::future - enqueueUpload(const std::string & uri, std::string data, const Headers & headers = {}) = 0; + virtual void + upload(const std::string & uri, std::string data, const Headers & headers = {}) = 0; /** * Checks whether the given URI exists. For historical reasons this function diff --git a/src/libstore/http-binary-cache-store.cc b/src/libstore/http-binary-cache-store.cc index c7bfb8e0c..4afec752f 100644 --- a/src/libstore/http-binary-cache-store.cc +++ b/src/libstore/http-binary-cache-store.cc @@ -127,9 +127,7 @@ protected: { auto data = StreamToSourceAdapter(istream).drain(); try { - getFileTransfer() - ->enqueueUpload(makeURI(path), std::move(data), {{"Content-Type", mimeType}}) - .get(); + getFileTransfer()->upload(makeURI(path), std::move(data), {{"Content-Type", mimeType}}); } catch (FileTransferError & e) { throw UploadToHTTP( "while uploading to HTTP binary cache at '%s': %s", cacheUri, e.msg()