Get rid of verifyAllValidPaths boolean blindness

This commit is contained in:
John Ericson 2023-12-11 13:28:40 -05:00
parent c30b5d8a0b
commit b21ee60594
4 changed files with 33 additions and 9 deletions

View file

@ -252,7 +252,7 @@ void LocalOverlayStore::optimiseStore()
} }
std::pair<bool, StorePathSet> LocalOverlayStore::verifyAllValidPaths(RepairFlag repair) LocalStore::VerificationResult LocalOverlayStore::verifyAllValidPaths(RepairFlag repair)
{ {
StorePathSet done; StorePathSet done;
@ -266,7 +266,10 @@ std::pair<bool, StorePathSet> LocalOverlayStore::verifyAllValidPaths(RepairFlag
for (auto & i : queryAllValidPaths()) for (auto & i : queryAllValidPaths())
verifyPath(i, existsInStoreDir, done, validPaths, repair, errors); verifyPath(i, existsInStoreDir, done, validPaths, repair, errors);
return { errors, validPaths }; return {
.errors = errors,
.validPaths = validPaths,
};
} }

View file

@ -188,7 +188,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.
*/ */
std::pair<bool, StorePathSet> verifyAllValidPaths(RepairFlag repair) override; VerificationResult verifyAllValidPaths(RepairFlag repair) override;
/** /**
* Deletion only effects the upper layer, so we ignore lower-layer referrers. * Deletion only effects the upper layer, so we ignore lower-layer referrers.

View file

@ -1443,7 +1443,7 @@ bool LocalStore::verifyStore(bool checkContents, RepairFlag repair)
} }
std::pair<bool, StorePathSet> LocalStore::verifyAllValidPaths(RepairFlag repair) LocalStore::VerificationResult 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
@ -1476,7 +1476,10 @@ std::pair<bool, StorePathSet> LocalStore::verifyAllValidPaths(RepairFlag repair)
for (auto & i : queryAllValidPaths()) for (auto & i : queryAllValidPaths())
verifyPath(i, existsInStoreDir, done, validPaths, repair, errors); verifyPath(i, existsInStoreDir, done, validPaths, repair, errors);
return { errors, validPaths }; return {
.errors = errors,
.validPaths = validPaths,
};
} }

View file

@ -264,12 +264,30 @@ public:
bool verifyStore(bool checkContents, RepairFlag repair) override; bool verifyStore(bool checkContents, RepairFlag repair) override;
protected:
/** /**
* @return A pair of whether any errors were encountered, and a set of * Result of `verifyAllValidPaths`
* (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); struct VerificationResult {
/**
* Whether any errors were encountered
*/
bool errors;
/**
* A set of so-far valid paths. The store objects pointed to by
* those paths are suitable for further validation checking.
*/
StorePathSet validPaths;
};
/**
* First, unconditional step of `verifyStore`
*/
virtual VerificationResult verifyAllValidPaths(RepairFlag repair);
public:
/** /**
* Register the validity of a path, i.e., that `path` exists, that * Register the validity of a path, i.e., that `path` exists, that