From 04a2aba00a9ca58079e9f39f61fe1825a13ed71c Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Sun, 15 Jun 2025 14:47:08 +0200 Subject: [PATCH] libstore: explicitly init curl transfer sources this too will make it easier to make the streams async. Change-Id: I9a961fc667042e0aed23d2241326f1ea719bc7a4 --- lix/libstore/filetransfer.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lix/libstore/filetransfer.cc b/lix/libstore/filetransfer.cc index aa3311aaf..cc1443320 100644 --- a/lix/libstore/filetransfer.cc +++ b/lix/libstore/filetransfer.cc @@ -801,6 +801,7 @@ struct curlFileTransfer : public FileTransfer } auto source = make_box_ptr(*this, uri, headers, std::move(data), noBody); + source->init(); source->awaitData(); co_return {source->metadata, std::move(source)}; } catch (...) { @@ -838,8 +839,6 @@ struct curlFileTransfer : public FileTransfer , data(std::move(data)) , noBody(noBody) { - auto setup = [&] { return startTransfer(uri); }; - metadata = withRetries(setup, setup); } ~TransferSource() @@ -854,6 +853,12 @@ struct curlFileTransfer : public FileTransfer } } + void init() + { + auto setup = [&] { return startTransfer(uri); }; + metadata = withRetries(setup, setup); + } + auto withRetries(auto && initial, auto && retry) -> decltype(initial()) { std::optional retryContext;