libstore: asyncify Store::getProtocol
Change-Id: I52744d925d1239fd326a3ec4e3a26e8e8ca44be0
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user