libstore: rpc-ish-ify remaining RemoteStore methods
oops, forgot a few Change-Id: Ic9ed34c29d26e94109d5f69eb90f334f26170ec3
This commit is contained in:
@@ -265,10 +265,14 @@ kj::Promise<Result<std::shared_ptr<const ValidPathInfo>>>
|
||||
RemoteStore::queryPathInfoUncached(const StorePath & path)
|
||||
try {
|
||||
auto conn(TRY_AWAIT(getConnection()));
|
||||
std::optional<UnkeyedValidPathInfo> pathInfo;
|
||||
try {
|
||||
auto valid =
|
||||
TRY_AWAIT(conn.sendCommand<bool>(WorkerProto::Op::QueryPathInfo, printStorePath(path)));
|
||||
if (!valid) co_return result::success(nullptr);
|
||||
pathInfo = TRY_AWAIT(conn.sendCommand<std::optional<UnkeyedValidPathInfo>>(
|
||||
WorkerProto::Op::QueryPathInfo, printStorePath(path)
|
||||
));
|
||||
if (!pathInfo) {
|
||||
co_return result::success(nullptr);
|
||||
}
|
||||
} catch (Error & e) {
|
||||
// Ugly backwards compatibility hack. TODO(fj#325): remove.
|
||||
if (e.msg().find("is not valid") != std::string::npos)
|
||||
@@ -276,9 +280,7 @@ try {
|
||||
throw;
|
||||
}
|
||||
|
||||
co_return std::make_shared<ValidPathInfo>(
|
||||
StorePath{path},
|
||||
WorkerProto::Serialise<UnkeyedValidPathInfo>::read(*conn));
|
||||
co_return std::make_shared<ValidPathInfo>(StorePath{path}, std::move(*pathInfo));
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
@@ -288,9 +290,9 @@ kj::Promise<Result<void>> RemoteStore::queryReferrers(const StorePath & path,
|
||||
StorePathSet & referrers)
|
||||
try {
|
||||
auto conn(TRY_AWAIT(getConnection()));
|
||||
TRY_AWAIT(conn.sendCommand(WorkerProto::Op::QueryReferrers, printStorePath(path)));
|
||||
for (auto & i : WorkerProto::Serialise<StorePathSet>::read(*conn))
|
||||
referrers.insert(i);
|
||||
referrers.merge(TRY_AWAIT(
|
||||
conn.sendCommand<StorePathSet>(WorkerProto::Op::QueryReferrers, printStorePath(path))
|
||||
));
|
||||
co_return result::success();
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "lix/libstore/worker-protocol-impl.hh"
|
||||
#include "lix/libutil/archive.hh"
|
||||
#include "lix/libstore/path-info.hh"
|
||||
#include <optional>
|
||||
|
||||
namespace nix {
|
||||
|
||||
@@ -152,6 +153,27 @@ WireFormatGenerator WorkerProto::Serialise<UnkeyedValidPathInfo>::write(WriteCon
|
||||
co_yield renderContentAddress(pathInfo.ca);
|
||||
}
|
||||
|
||||
std::optional<UnkeyedValidPathInfo>
|
||||
WorkerProto::Serialise<std::optional<UnkeyedValidPathInfo>>::read(ReadConn conn)
|
||||
{
|
||||
bool valid;
|
||||
conn.from >> valid;
|
||||
if (valid) {
|
||||
return WorkerProto::Serialise<UnkeyedValidPathInfo>::read(conn);
|
||||
} else {
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
WireFormatGenerator WorkerProto::Serialise<std::optional<UnkeyedValidPathInfo>>::write(
|
||||
WriteConn conn, const std::optional<UnkeyedValidPathInfo> & pathInfo
|
||||
)
|
||||
{
|
||||
co_yield pathInfo.has_value();
|
||||
if (pathInfo.has_value()) {
|
||||
co_yield WorkerProto::write(conn, *pathInfo);
|
||||
}
|
||||
}
|
||||
|
||||
SubstitutablePathInfo WorkerProto::Serialise<SubstitutablePathInfo>::read(ReadConn conn)
|
||||
{
|
||||
|
||||
@@ -239,6 +239,8 @@ DECLARE_WORKER_SERIALISER(UnkeyedValidPathInfo);
|
||||
template<>
|
||||
DECLARE_WORKER_SERIALISER(std::optional<TrustedFlag>);
|
||||
template<>
|
||||
DECLARE_WORKER_SERIALISER(std::optional<UnkeyedValidPathInfo>);
|
||||
template<>
|
||||
DECLARE_WORKER_SERIALISER(SubstitutablePathInfo);
|
||||
|
||||
template<typename T>
|
||||
|
||||
Reference in New Issue
Block a user