Support --keep-going in nix repair

This commit is contained in:
Robert Hensing 2024-11-13 13:00:32 +01:00
parent 11593d44aa
commit 93c1d1a976

View File

@ -19,8 +19,32 @@ struct CmdStoreRepair : StorePathsCommand
void run(ref<Store> store, StorePaths && storePaths) override
{
size_t errors = 0;
// Remove duplicates.
StorePathSet storePathsSet;
for (auto & path : storePaths)
storePathsSet.insert(path);
for (auto & path : storePathsSet) {
try {
store->repairPath(path);
} catch (Error & e) {
// RepairFailure already has the path in the error message, so we omit the redundant trace.
if (!dynamic_cast<RepairFailure *>(&e))
e.addTrace({}, "while repairing path '%s'", store->printStorePath(path));
if (settings.keepGoing) {
errors++;
ignoreExceptionExceptInterrupt();
}
else
throw;
}
}
if (errors)
throw Error("could not repair %d store paths", errors);
}
};