libstore: asyncify Store::pathInfoToJSON

Change-Id: I2e04c6804444b3ca53486ce6acb0c159e7814938
This commit is contained in:
eldritch horrors
2025-02-08 17:01:31 +00:00
parent 6ffa9f4298
commit 6e95540610
4 changed files with 10 additions and 8 deletions
+2 -2
View File
@@ -155,9 +155,9 @@ try {
StorePathSet storePaths;
for (auto & p : *i)
storePaths.insert(store.toStorePath(p.get<std::string>()).first);
json[i.key()] = store.pathInfoToJSON(
json[i.key()] = TRY_AWAIT(store.pathInfoToJSON(
TRY_AWAIT(store.exportReferences(storePaths, inputPaths)), false, true
);
));
}
}
+5 -3
View File
@@ -962,11 +962,11 @@ try {
co_return result::current_exception();
}
json Store::pathInfoToJSON(const StorePathSet & storePaths,
kj::Promise<Result<json>> Store::pathInfoToJSON(const StorePathSet & storePaths,
bool includeImpureInfo, bool showClosureSize,
Base hashBase,
AllowInvalidFlag allowInvalid)
{
try {
json::array_t jsonList = json::array();
for (auto & storePath : storePaths) {
@@ -1032,7 +1032,9 @@ json Store::pathInfoToJSON(const StorePathSet & storePaths,
jsonPath["valid"] = false;
}
}
return jsonList;
co_return jsonList;
} catch (...) {
co_return result::current_exception();
}
+1 -1
View File
@@ -686,7 +686,7 @@ public:
* @param showClosureSize If true, the closure size of each path is
* included.
*/
nlohmann::json pathInfoToJSON(const StorePathSet & storePaths,
kj::Promise<Result<nlohmann::json>> pathInfoToJSON(const StorePathSet & storePaths,
bool includeImpureInfo, bool showClosureSize,
Base hashBase = Base::Base32,
AllowInvalidFlag allowInvalid = DisallowInvalid);
+2 -2
View File
@@ -91,10 +91,10 @@ struct CmdPathInfo : StorePathsCommand, MixJSON
pathLen = std::max(pathLen, store->printStorePath(storePath).size());
if (json) {
std::cout << store->pathInfoToJSON(
std::cout << aio().blockOn(store->pathInfoToJSON(
// FIXME: preserve order?
StorePathSet(storePaths.begin(), storePaths.end()),
true, showClosureSize, Base::SRI, AllowInvalid).dump();
true, showClosureSize, Base::SRI, AllowInvalid)).dump();
}
else {