From 17965bf11c55daee81729151f9876e55fdeaf9c1 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Sat, 27 Apr 2024 23:44:12 +0200 Subject: libstore: un-callback-ify Store::queryRealisationUncached Change-Id: I4a328f46eaac3bb8b19ddc091306de83348be9cf --- src/libstore/remote-store.cc | 51 +++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 29 deletions(-) (limited to 'src/libstore/remote-store.cc') diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index 94c426c02..1d3fa93c1 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -612,39 +612,32 @@ void RemoteStore::registerDrvOutput(const Realisation & info) conn.processStderr(); } -void RemoteStore::queryRealisationUncached(const DrvOutput & id, - Callback> callback) noexcept +std::shared_ptr RemoteStore::queryRealisationUncached(const DrvOutput & id) { - try { - auto conn(getConnection()); - - if (GET_PROTOCOL_MINOR(conn->daemonVersion) < 27) { - warn("the daemon is too old to support content-addressed derivations, please upgrade it to 2.4"); - return callback(nullptr); - } + auto conn(getConnection()); - conn->to << WorkerProto::Op::QueryRealisation; - conn->to << id.to_string(); - conn.processStderr(); + if (GET_PROTOCOL_MINOR(conn->daemonVersion) < 27) { + warn("the daemon is too old to support content-addressed derivations, please upgrade it to 2.4"); + return nullptr; + } - auto real = [&]() -> std::shared_ptr { - if (GET_PROTOCOL_MINOR(conn->daemonVersion) < 31) { - auto outPaths = WorkerProto::Serialise>::read( - *this, *conn); - if (outPaths.empty()) - return nullptr; - return std::make_shared(Realisation { .id = id, .outPath = *outPaths.begin() }); - } else { - auto realisations = WorkerProto::Serialise>::read( - *this, *conn); - if (realisations.empty()) - return nullptr; - return std::make_shared(*realisations.begin()); - } - }(); + conn->to << WorkerProto::Op::QueryRealisation; + conn->to << id.to_string(); + conn.processStderr(); - callback(std::shared_ptr(real)); - } catch (...) { return callback.rethrow(); } + if (GET_PROTOCOL_MINOR(conn->daemonVersion) < 31) { + auto outPaths = WorkerProto::Serialise>::read( + *this, *conn); + if (outPaths.empty()) + return nullptr; + return std::make_shared(Realisation { .id = id, .outPath = *outPaths.begin() }); + } else { + auto realisations = WorkerProto::Serialise>::read( + *this, *conn); + if (realisations.empty()) + return nullptr; + return std::make_shared(*realisations.begin()); + } } void RemoteStore::copyDrvsFromEvalStore( -- cgit v1.2.3