mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-14 10:16:15 +02:00
Make verifyAllValidPaths
more functional
return map rather than mutate one passed in by reference
This commit is contained in:
parent
73c9fc7ab1
commit
6b297e5895
4 changed files with 19 additions and 12 deletions
|
@ -243,19 +243,21 @@ void LocalOverlayStore::optimiseStore()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LocalOverlayStore::verifyAllValidPaths(RepairFlag repair, StorePathSet & validPaths)
|
std::pair<bool, StorePathSet> LocalOverlayStore::verifyAllValidPaths(RepairFlag repair)
|
||||||
{
|
{
|
||||||
StorePathSet done;
|
StorePathSet done;
|
||||||
bool errors = false;
|
|
||||||
|
|
||||||
auto existsInStoreDir = [&](const StorePath & storePath) {
|
auto existsInStoreDir = [&](const StorePath & storePath) {
|
||||||
return pathExists(realStoreDir.get() + "/" + storePath.to_string());
|
return pathExists(realStoreDir.get() + "/" + storePath.to_string());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool errors = false;
|
||||||
|
StorePathSet validPaths;
|
||||||
|
|
||||||
for (auto & i : queryAllValidPaths())
|
for (auto & i : queryAllValidPaths())
|
||||||
verifyPath(i, existsInStoreDir, done, validPaths, repair, errors);
|
verifyPath(i, existsInStoreDir, done, validPaths, repair, errors);
|
||||||
|
|
||||||
return errors;
|
return { errors, validPaths };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,7 @@ private:
|
||||||
* We don't verify the contents of both layers on the assumption that the lower layer is far bigger,
|
* We don't verify the contents of both layers on the assumption that the lower layer is far bigger,
|
||||||
* and also the observation that anything not in the upper db the overlayfs doesn't yet care about.
|
* and also the observation that anything not in the upper db the overlayfs doesn't yet care about.
|
||||||
*/
|
*/
|
||||||
bool verifyAllValidPaths(RepairFlag repair, StorePathSet & validPaths) override;
|
std::pair<bool, StorePathSet> verifyAllValidPaths(RepairFlag repair) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For lower-store paths, we used the lower store location. This avoids the
|
* For lower-store paths, we used the lower store location. This avoids the
|
||||||
|
|
|
@ -1503,9 +1503,7 @@ bool LocalStore::verifyStore(bool checkContents, RepairFlag repair)
|
||||||
auto fdGCLock = openGCLock();
|
auto fdGCLock = openGCLock();
|
||||||
FdLock gcLock(fdGCLock.get(), ltRead, true, "waiting for the big garbage collector lock...");
|
FdLock gcLock(fdGCLock.get(), ltRead, true, "waiting for the big garbage collector lock...");
|
||||||
|
|
||||||
StorePathSet validPaths;
|
auto [errors, validPaths] = verifyAllValidPaths(repair);
|
||||||
|
|
||||||
bool errors = verifyAllValidPaths(repair, validPaths);
|
|
||||||
|
|
||||||
/* Optionally, check the content hashes (slow). */
|
/* Optionally, check the content hashes (slow). */
|
||||||
if (checkContents) {
|
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;
|
StorePathSet storePathsInStoreDir;
|
||||||
/* Why aren't we using `queryAllValidPaths`? Because that would
|
/* Why aren't we using `queryAllValidPaths`? Because that would
|
||||||
|
@ -1613,16 +1611,18 @@ bool LocalStore::verifyAllValidPaths(RepairFlag repair, StorePathSet & validPath
|
||||||
printInfo("checking path existence...");
|
printInfo("checking path existence...");
|
||||||
|
|
||||||
StorePathSet done;
|
StorePathSet done;
|
||||||
bool errors = false;
|
|
||||||
|
|
||||||
auto existsInStoreDir = [&](const StorePath & storePath) {
|
auto existsInStoreDir = [&](const StorePath & storePath) {
|
||||||
return storePathsInStoreDir.count(storePath);
|
return storePathsInStoreDir.count(storePath);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool errors = false;
|
||||||
|
StorePathSet validPaths;
|
||||||
|
|
||||||
for (auto & i : queryAllValidPaths())
|
for (auto & i : queryAllValidPaths())
|
||||||
verifyPath(i, existsInStoreDir, done, validPaths, repair, errors);
|
verifyPath(i, existsInStoreDir, done, validPaths, repair, errors);
|
||||||
|
|
||||||
return errors;
|
return { errors, validPaths };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -265,7 +265,12 @@ public:
|
||||||
|
|
||||||
bool verifyStore(bool checkContents, RepairFlag repair) override;
|
bool verifyStore(bool checkContents, RepairFlag repair) override;
|
||||||
|
|
||||||
virtual bool verifyAllValidPaths(RepairFlag repair, StorePathSet & validPaths);
|
/**
|
||||||
|
* @return A pair of whether any errors were encountered, and a set of
|
||||||
|
* (so-far) valid paths. The store objects pointed to by those paths are
|
||||||
|
* suitable for further validation checking.
|
||||||
|
*/
|
||||||
|
virtual std::pair<bool, StorePathSet> verifyAllValidPaths(RepairFlag repair);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register the validity of a path, i.e., that `path` exists, that
|
* Register the validity of a path, i.e., that `path` exists, that
|
||||||
|
|
Loading…
Reference in a new issue