libstore: asyncify Store::getProtocol

Change-Id: I52744d925d1239fd326a3ec4e3a26e8e8ca44be0
This commit is contained in:
eldritch horrors
2025-03-05 16:42:11 +01:00
parent a783d2c0d9
commit 12e9b8da0f
7 changed files with 20 additions and 16 deletions
+5 -3
View File
@@ -439,10 +439,12 @@ public:
co_return result::current_exception();
}
unsigned int getProtocol() override
{
kj::Promise<Result<unsigned int>> getProtocol() override
try {
auto conn(connections->get());
return conn->remoteVersion;
co_return conn->remoteVersion;
} catch (...) {
co_return result::current_exception();
}
/**
+2 -2
View File
@@ -1740,9 +1740,9 @@ try {
}
unsigned int LocalStore::getProtocol()
kj::Promise<Result<unsigned int>> LocalStore::getProtocol()
{
return PROTOCOL_VERSION;
return {result::success(PROTOCOL_VERSION)};
}
std::optional<TrustedFlag> LocalStore::isTrustedClient()
+1 -1
View File
@@ -298,7 +298,7 @@ public:
void registerValidPaths(const ValidPathInfos & infos);
unsigned int getProtocol() override;
kj::Promise<Result<unsigned int>> getProtocol() override;
std::optional<TrustedFlag> isTrustedClient() override;
+8 -6
View File
@@ -322,7 +322,7 @@ StorePathSet RemoteStore::queryValidDerivers(const StorePath & path)
kj::Promise<Result<StorePathSet>> RemoteStore::queryDerivationOutputs(const StorePath & path)
try {
if (GET_PROTOCOL_MINOR(getProtocol()) >= 22) {
if (GET_PROTOCOL_MINOR(TRY_AWAIT(getProtocol())) >= 22) {
co_return TRY_AWAIT(Store::queryDerivationOutputs(path));
}
REMOVE_AFTER_DROPPING_PROTO_MINOR(21);
@@ -338,7 +338,7 @@ try {
kj ::Promise<Result<std::map<std::string, std::optional<StorePath>>>>
RemoteStore::queryPartialDerivationOutputMap(const StorePath & path, Store * evalStore_)
try {
if (GET_PROTOCOL_MINOR(getProtocol()) >= 22) {
if (GET_PROTOCOL_MINOR(TRY_AWAIT(getProtocol())) >= 22) {
if (!evalStore_) {
auto conn(getConnection());
conn->to << WorkerProto::Op::QueryDerivationOutputMap << printStorePath(path);
@@ -551,7 +551,7 @@ kj::Promise<Result<void>> RemoteStore::addMultipleToStore(
CheckSigsFlag checkSigs)
try {
if (GET_PROTOCOL_MINOR(getConnection()->daemonVersion) >= 32) {
auto remoteVersion = getProtocol();
auto remoteVersion = TRY_AWAIT(getProtocol());
auto conn(getConnection());
conn->to
@@ -944,10 +944,12 @@ try {
}
unsigned int RemoteStore::getProtocol()
{
kj::Promise<Result<unsigned int>> RemoteStore::getProtocol()
try {
auto conn(connections->get());
return conn->daemonVersion;
co_return conn->daemonVersion;
} catch (...) {
co_return result::current_exception();
}
std::optional<TrustedFlag> RemoteStore::isTrustedClient()
+1 -1
View File
@@ -167,7 +167,7 @@ public:
kj::Promise<Result<void>> connect() override;
unsigned int getProtocol() override;
kj::Promise<Result<unsigned int>> getProtocol() override;
std::optional<TrustedFlag> isTrustedClient() override;
+2 -2
View File
@@ -867,9 +867,9 @@ public:
/**
* Get the protocol version of this store or it's connection.
*/
virtual unsigned int getProtocol()
virtual kj::Promise<Result<unsigned int>> getProtocol()
{
return 0;
return {result::success(0)};
};
/**
+1 -1
View File
@@ -66,7 +66,7 @@ struct CmdDoctor : StoreCommand
success &= checkNixInPath();
success &= checkProfileRoots(store);
}
success &= checkStoreProtocol(store->getProtocol());
success &= checkStoreProtocol(aio().blockOn(store->getProtocol()));
checkTrustedUser(store);
if (!success)