libstore: asyncify Store::exportReferences

Change-Id: Ia4068d31afc48cf9d459bed3d5d8943be06718ee
This commit is contained in:
eldritch horrors
2025-02-04 14:11:08 +00:00
parent de66d7b2b4
commit 6423ee2b7e
4 changed files with 17 additions and 8 deletions
+5 -2
View File
@@ -571,9 +571,12 @@ try {
auto storePath = worker.store.toStorePath(storePathS).first;
/* Write closure info to <fileName>. */
writeFile(tmpDir + "/" + fileName,
writeFile(
tmpDir + "/" + fileName,
worker.store.makeValidityRegistration(
worker.store.exportReferences({storePath}, inputPaths), false, false));
TRY_AWAIT(worker.store.exportReferences({storePath}, inputPaths)), false, false
)
);
}
}
+3 -1
View File
@@ -1,4 +1,5 @@
#include "lix/libstore/parsed-derivations.hh"
#include "lix/libutil/async.hh"
#include "lix/libutil/strings.hh"
#include <nlohmann/json.hpp>
@@ -154,7 +155,8 @@ std::optional<nlohmann::json> ParsedDerivation::prepareStructuredAttrs(Store & s
for (auto & p : *i)
storePaths.insert(store.toStorePath(p.get<std::string>()).first);
json[i.key()] = store.pathInfoToJSON(
store.exportReferences(storePaths, inputPaths), false, true);
RUN_ASYNC_IN_NEW_THREAD(store.exportReferences(storePaths, inputPaths)), false, true
);
}
}
+7 -4
View File
@@ -918,8 +918,9 @@ std::string Store::makeValidityRegistration(const StorePathSet & paths,
}
StorePathSet Store::exportReferences(const StorePathSet & storePaths, const StorePathSet & inputPaths)
{
kj::Promise<Result<StorePathSet>>
Store::exportReferences(const StorePathSet & storePaths, const StorePathSet & inputPaths)
try {
StorePathSet paths;
for (auto & storePath : storePaths) {
@@ -937,7 +938,7 @@ StorePathSet Store::exportReferences(const StorePathSet & storePaths, const Stor
for (auto & j : paths2) {
if (j.isDerivation()) {
Derivation drv = RUN_ASYNC_IN_NEW_THREAD(derivationFromPath(j));
Derivation drv = TRY_AWAIT(derivationFromPath(j));
for (auto & k : drv.outputsAndOptPaths(*this)) {
if (!k.second.second)
/* FIXME: I am confused why we are calling
@@ -950,7 +951,9 @@ StorePathSet Store::exportReferences(const StorePathSet & storePaths, const Stor
}
}
return paths;
co_return paths;
} catch (...) {
co_return result::current_exception();
}
json Store::pathInfoToJSON(const StorePathSet & storePaths,
+2 -1
View File
@@ -818,7 +818,8 @@ public:
* Computes the full closure of of a set of store-paths for e.g.
* derivations that need this information for `exportReferencesGraph`.
*/
StorePathSet exportReferences(const StorePathSet & storePaths, const StorePathSet & inputPaths);
kj::Promise<Result<StorePathSet>>
exportReferences(const StorePathSet & storePaths, const StorePathSet & inputPaths);
/**
* Given a store path, return the realisation actually used in the realisation of this path: