1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-20 17:29:36 +01:00

Make verifyAllValidPaths more functional

return map rather than mutate one passed in by reference
This commit is contained in:
John Ericson 2023-08-02 14:38:22 -04:00
parent 73c9fc7ab1
commit 6b297e5895
4 changed files with 19 additions and 12 deletions

View file

@ -1503,9 +1503,7 @@ bool LocalStore::verifyStore(bool checkContents, RepairFlag repair)
auto fdGCLock = openGCLock();
FdLock gcLock(fdGCLock.get(), ltRead, true, "waiting for the big garbage collector lock...");
StorePathSet validPaths;
bool errors = verifyAllValidPaths(repair, validPaths);
auto [errors, validPaths] = verifyAllValidPaths(repair);
/* Optionally, check the content hashes (slow). */
if (checkContents) {
@ -1591,7 +1589,7 @@ bool LocalStore::verifyStore(bool checkContents, RepairFlag repair)
}
bool LocalStore::verifyAllValidPaths(RepairFlag repair, StorePathSet & validPaths)
std::pair<bool, StorePathSet> LocalStore::verifyAllValidPaths(RepairFlag repair)
{
StorePathSet storePathsInStoreDir;
/* Why aren't we using `queryAllValidPaths`? Because that would
@ -1613,16 +1611,18 @@ bool LocalStore::verifyAllValidPaths(RepairFlag repair, StorePathSet & validPath
printInfo("checking path existence...");
StorePathSet done;
bool errors = false;
auto existsInStoreDir = [&](const StorePath & storePath) {
return storePathsInStoreDir.count(storePath);
};
bool errors = false;
StorePathSet validPaths;
for (auto & i : queryAllValidPaths())
verifyPath(i, existsInStoreDir, done, validPaths, repair, errors);
return errors;
return { errors, validPaths };
}