diff options
author | eldritch horrors <pennae@lix.systems> | 2024-04-27 21:24:36 +0200 |
---|---|---|
committer | eldritch horrors <pennae@lix.systems> | 2024-05-09 23:18:05 +0200 |
commit | 2f4a1dd6e03f3005e1f11dc98dda2d2d214b1f6f (patch) | |
tree | a9c0d70d2c4fa611d4c405ec81ac2b8f9c9bf3cf /src/libstore/remote-store.cc | |
parent | c77bd88259dac6e6b7bcb29425905467aa2ef66f (diff) |
libstore: de-callback-ify Store::queryPathInfoUncached
Change-Id: I23a156aaff5328f67ca16ccd85c0ea1711b21e35
Diffstat (limited to 'src/libstore/remote-store.cc')
-rw-r--r-- | src/libstore/remote-store.cc | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index 20c1c50f2..94c426c02 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -304,32 +304,25 @@ void RemoteStore::querySubstitutablePathInfos(const StorePathCAMap & pathsMap, S } -void RemoteStore::queryPathInfoUncached(const StorePath & path, - Callback<std::shared_ptr<const ValidPathInfo>> callback) noexcept +std::shared_ptr<const ValidPathInfo> RemoteStore::queryPathInfoUncached(const StorePath & path) { + auto conn(getConnection()); + conn->to << WorkerProto::Op::QueryPathInfo << printStorePath(path); try { - std::shared_ptr<const ValidPathInfo> info; - { - auto conn(getConnection()); - conn->to << WorkerProto::Op::QueryPathInfo << printStorePath(path); - try { - conn.processStderr(); - } catch (Error & e) { - // Ugly backwards compatibility hack. - if (e.msg().find("is not valid") != std::string::npos) - throw InvalidPath(std::move(e.info())); - throw; - } - if (GET_PROTOCOL_MINOR(conn->daemonVersion) >= 17) { - bool valid; conn->from >> valid; - if (!valid) throw InvalidPath("path '%s' is not valid", printStorePath(path)); - } - info = std::make_shared<ValidPathInfo>( - StorePath{path}, - WorkerProto::Serialise<UnkeyedValidPathInfo>::read(*this, *conn)); - } - callback(std::move(info)); - } catch (...) { callback.rethrow(); } + conn.processStderr(); + } catch (Error & e) { + // Ugly backwards compatibility hack. + if (e.msg().find("is not valid") != std::string::npos) + throw InvalidPath(std::move(e.info())); + throw; + } + if (GET_PROTOCOL_MINOR(conn->daemonVersion) >= 17) { + bool valid; conn->from >> valid; + if (!valid) throw InvalidPath("path '%s' is not valid", printStorePath(path)); + } + return std::make_shared<ValidPathInfo>( + StorePath{path}, + WorkerProto::Serialise<UnkeyedValidPathInfo>::read(*this, *conn)); } |