1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-06 00:51:47 +02:00

nix-store --verify: Add an option ‘--repair’ to repair all missing/corrupt paths

Also, return a non-zero exit code if errors remain after
verifying/repairing.
This commit is contained in:
Eelco Dolstra 2012-10-02 15:04:59 -04:00
parent 9958bd6992
commit 8e3a7bd712
4 changed files with 42 additions and 11 deletions

View file

@ -703,13 +703,18 @@ static void opVerify(Strings opFlags, Strings opArgs)
throw UsageError("no arguments expected");
bool checkContents = false;
bool repair = false;
for (Strings::iterator i = opFlags.begin();
i != opFlags.end(); ++i)
if (*i == "--check-contents") checkContents = true;
else if (*i == "--repair") repair = true;
else throw UsageError(format("unknown flag `%1%'") % *i);
ensureLocalStore().verifyStore(checkContents);
if (ensureLocalStore().verifyStore(checkContents, repair)) {
printMsg(lvlError, "warning: not all errors were fixed");
exitCode = 1;
}
}
@ -743,7 +748,6 @@ static void opRepairPath(Strings opFlags, Strings opArgs)
foreach (Strings::iterator, i, opArgs) {
Path path = followLinksToStorePath(*i);
printMsg(lvlTalkative, format("repairing path `%1%'...") % path);
ensureLocalStore().repairPath(path);
}
}