libstore: asyncify Store::queryStaticPartialDerivationOutputMap
Change-Id: Iba6dd8197a51c43f7d38d7b15b153c5acd0c7f5b
This commit is contained in:
+21
-13
@@ -1069,21 +1069,29 @@ StorePathSet LocalStore::queryValidDerivers(const StorePath & path)
|
||||
}
|
||||
|
||||
|
||||
std::map<std::string, std::optional<StorePath>>
|
||||
kj::Promise<Result<std::map<std::string, std::optional<StorePath>>>>
|
||||
LocalStore::queryStaticPartialDerivationOutputMap(const StorePath & path)
|
||||
{
|
||||
return retrySQLite([&]() {
|
||||
auto state = dbPool.get();
|
||||
std::map<std::string, std::optional<StorePath>> outputs;
|
||||
uint64_t drvId;
|
||||
drvId = queryValidPathId(*state, path);
|
||||
auto use(state->stmts->QueryDerivationOutputs.use()(drvId));
|
||||
while (use.next())
|
||||
outputs.insert_or_assign(
|
||||
use.getStr(0), parseStorePath(use.getStr(1)));
|
||||
try {
|
||||
co_return TRY_AWAIT(
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-capturing-lambda-coroutines)
|
||||
retrySQLite([&]() -> kj::Promise<Result<std::map<std::string, std::optional<StorePath>>>> {
|
||||
try {
|
||||
auto state = dbPool.get();
|
||||
std::map<std::string, std::optional<StorePath>> outputs;
|
||||
uint64_t drvId;
|
||||
drvId = queryValidPathId(*state, path);
|
||||
auto use(state->stmts->QueryDerivationOutputs.use()(drvId));
|
||||
while (use.next())
|
||||
outputs.insert_or_assign(use.getStr(0), parseStorePath(use.getStr(1)));
|
||||
|
||||
return outputs;
|
||||
}, always_progresses);
|
||||
co_return outputs;
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
})
|
||||
);
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
|
||||
kj::Promise<Result<std::optional<StorePath>>>
|
||||
|
||||
@@ -202,7 +202,8 @@ public:
|
||||
|
||||
StorePathSet queryValidDerivers(const StorePath & path) override;
|
||||
|
||||
std::map<std::string, std::optional<StorePath>> queryStaticPartialDerivationOutputMap(const StorePath & path) override;
|
||||
kj::Promise<Result<std::map<std::string, std::optional<StorePath>>>>
|
||||
queryStaticPartialDerivationOutputMap(const StorePath & path) override;
|
||||
|
||||
kj::Promise<Result<std::optional<StorePath>>>
|
||||
queryPathFromHashPart(const std::string & hashPart) override;
|
||||
|
||||
@@ -352,7 +352,7 @@ try {
|
||||
);
|
||||
} else {
|
||||
auto & evalStore = *evalStore_;
|
||||
auto outputs = evalStore.queryStaticPartialDerivationOutputMap(path);
|
||||
auto outputs = TRY_AWAIT(evalStore.queryStaticPartialDerivationOutputMap(path));
|
||||
// union with the first branch overriding the statically-known ones
|
||||
// when non-`std::nullopt`.
|
||||
for (auto && [outputName, optPath] :
|
||||
@@ -374,7 +374,7 @@ try {
|
||||
// from the derivation itself (and not the ones that are known because
|
||||
// the have been built), but as old stores don't handle floating-CA
|
||||
// derivations this shouldn't matter
|
||||
co_return evalStore.queryStaticPartialDerivationOutputMap(path);
|
||||
co_return TRY_AWAIT(evalStore.queryStaticPartialDerivationOutputMap(path));
|
||||
}
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
|
||||
@@ -506,14 +506,17 @@ bool Store::PathInfoCacheValue::isKnownNow()
|
||||
return std::chrono::steady_clock::now() < time_point + ttl;
|
||||
}
|
||||
|
||||
std::map<std::string, std::optional<StorePath>> Store::queryStaticPartialDerivationOutputMap(const StorePath & path)
|
||||
{
|
||||
kj::Promise<Result<std::map<std::string, std::optional<StorePath>>>>
|
||||
Store::queryStaticPartialDerivationOutputMap(const StorePath & path)
|
||||
try {
|
||||
std::map<std::string, std::optional<StorePath>> outputs;
|
||||
auto drv = readInvalidDerivation(path);
|
||||
for (auto & [outputName, output] : drv.outputsAndOptPaths(*this)) {
|
||||
outputs.emplace(outputName, output.second);
|
||||
}
|
||||
return outputs;
|
||||
co_return outputs;
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
|
||||
kj::Promise<Result<std::map<std::string, std::optional<StorePath>>>>
|
||||
@@ -521,7 +524,7 @@ Store::queryPartialDerivationOutputMap(const StorePath & path, Store * evalStore
|
||||
try {
|
||||
auto & evalStore = evalStore_ ? *evalStore_ : *this;
|
||||
|
||||
auto outputs = evalStore.queryStaticPartialDerivationOutputMap(path);
|
||||
auto outputs = TRY_AWAIT(evalStore.queryStaticPartialDerivationOutputMap(path));
|
||||
|
||||
if (!experimentalFeatureSettings.isEnabled(Xp::CaDerivations))
|
||||
co_return outputs;
|
||||
|
||||
@@ -463,8 +463,8 @@ public:
|
||||
* Just a helper function for implementing
|
||||
* `queryPartialDerivationOutputMap`.
|
||||
*/
|
||||
virtual std::map<std::string, std::optional<StorePath>> queryStaticPartialDerivationOutputMap(
|
||||
const StorePath & path);
|
||||
virtual kj::Promise<Result<std::map<std::string, std::optional<StorePath>>>>
|
||||
queryStaticPartialDerivationOutputMap(const StorePath & path);
|
||||
|
||||
/**
|
||||
* Query the mapping outputName=>outputPath for the given derivation.
|
||||
|
||||
Reference in New Issue
Block a user