diff options
author | eldritch horrors <pennae@lix.systems> | 2024-04-27 23:44:12 +0200 |
---|---|---|
committer | eldritch horrors <pennae@lix.systems> | 2024-05-09 23:18:05 +0200 |
commit | 17965bf11c55daee81729151f9876e55fdeaf9c1 (patch) | |
tree | b4b7a4ce182e52acf2f8a4cdd6158638dc990162 /src/libstore/remote-store.cc | |
parent | 2f4a1dd6e03f3005e1f11dc98dda2d2d214b1f6f (diff) |
libstore: un-callback-ify Store::queryRealisationUncached
Change-Id: I4a328f46eaac3bb8b19ddc091306de83348be9cf
Diffstat (limited to 'src/libstore/remote-store.cc')
-rw-r--r-- | src/libstore/remote-store.cc | 51 |
1 files changed, 22 insertions, 29 deletions
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<std::shared_ptr<const Realisation>> callback) noexcept +std::shared_ptr<const Realisation> 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<const Realisation> { - if (GET_PROTOCOL_MINOR(conn->daemonVersion) < 31) { - auto outPaths = WorkerProto::Serialise<std::set<StorePath>>::read( - *this, *conn); - if (outPaths.empty()) - return nullptr; - return std::make_shared<const Realisation>(Realisation { .id = id, .outPath = *outPaths.begin() }); - } else { - auto realisations = WorkerProto::Serialise<std::set<Realisation>>::read( - *this, *conn); - if (realisations.empty()) - return nullptr; - return std::make_shared<const Realisation>(*realisations.begin()); - } - }(); + conn->to << WorkerProto::Op::QueryRealisation; + conn->to << id.to_string(); + conn.processStderr(); - callback(std::shared_ptr<const Realisation>(real)); - } catch (...) { return callback.rethrow(); } + if (GET_PROTOCOL_MINOR(conn->daemonVersion) < 31) { + auto outPaths = WorkerProto::Serialise<std::set<StorePath>>::read( + *this, *conn); + if (outPaths.empty()) + return nullptr; + return std::make_shared<const Realisation>(Realisation { .id = id, .outPath = *outPaths.begin() }); + } else { + auto realisations = WorkerProto::Serialise<std::set<Realisation>>::read( + *this, *conn); + if (realisations.empty()) + return nullptr; + return std::make_shared<const Realisation>(*realisations.begin()); + } } void RemoteStore::copyDrvsFromEvalStore( |