libstore: asyncify Derivation::checkInvariants

Change-Id: I269d5d11af811e4ab2f099fdc4e1c56597f38678
This commit is contained in:
eldritch horrors
2025-03-05 18:49:45 +01:00
parent 9d52d0db79
commit f43dbf3035
4 changed files with 10 additions and 6 deletions
+6 -2
View File
@@ -1161,8 +1161,9 @@ try {
}
void Derivation::checkInvariants(Store & store, const StorePath & drvPath) const
{
kj::Promise<Result<void>>
Derivation::checkInvariants(Store & store, const StorePath & drvPath) const
try {
assert(drvPath.isDerivation());
std::string drvName(drvPath.name());
drvName = drvName.substr(0, drvName.size() - drvExtension.size());
@@ -1218,6 +1219,9 @@ void Derivation::checkInvariants(Store & store, const StorePath & drvPath) const
},
}, i.second.raw);
}
co_return result::success();
} catch (...) {
co_return result::current_exception();
}
+1 -1
View File
@@ -362,7 +362,7 @@ struct Derivation : BasicDerivation
* representation supports all sorts of combinations we do not yet
* allow.
*/
void checkInvariants(Store & store, const StorePath & drvPath) const;
kj::Promise<Result<void>> checkInvariants(Store & store, const StorePath & drvPath) const;
Derivation() = default;
Derivation(const BasicDerivation & bd) : BasicDerivation(bd) { }
+2 -2
View File
@@ -894,7 +894,7 @@ try {
derivations). Note that if this throws an error, then the
DB transaction is rolled back, so the path validity
registration above is undone. */
if (checkOutputs) drv.checkInvariants(*this, info.path);
if (checkOutputs) TRY_AWAIT(drv.checkInvariants(*this, info.path));
for (auto & i : drv.outputsAndOptPaths(*this)) {
/* Floating CA derivations have indeterminate output paths until
@@ -1228,7 +1228,7 @@ try {
for (auto & [_, i] : infos)
if (i.path.isDerivation()) {
// FIXME: inefficient; we already loaded the derivation in addValidPath().
readInvalidDerivation(i.path).checkInvariants(*this, i.path);
TRY_AWAIT(readInvalidDerivation(i.path).checkInvariants(*this, i.path));
}
/* Do a topological sort of the paths. This will throw an
+1 -1
View File
@@ -34,7 +34,7 @@ struct CmdAddDerivation : MixDryRun, StoreCommand
auto drvPath = aio().blockOn(writeDerivation(*store, drv, NoRepair, /* read only */ dryRun));
drv.checkInvariants(*store, drvPath);
aio().blockOn(drv.checkInvariants(*store, drvPath));
aio().blockOn(writeDerivation(*store, drv, NoRepair, dryRun));