forked from lix-project/lix
Refactor verifyPath to take StorePath instead of Path.
This way we avoid having to convert from Path to StorePath and vice versa in the body of verifyPath.
This commit is contained in:
parent
2d1d81114d
commit
c9a87ce7ca
|
@ -1506,10 +1506,10 @@ bool LocalStore::verifyStore(bool checkContents, RepairFlag repair)
|
||||||
printInfo("checking path existence...");
|
printInfo("checking path existence...");
|
||||||
|
|
||||||
StorePathSet validPaths;
|
StorePathSet validPaths;
|
||||||
PathSet done;
|
StorePathSet done;
|
||||||
|
|
||||||
for (auto & i : queryAllValidPaths())
|
for (auto & i : queryAllValidPaths())
|
||||||
verifyPath(printStorePath(i), store, done, validPaths, repair, errors);
|
verifyPath(i, store, done, validPaths, repair, errors);
|
||||||
|
|
||||||
/* Optionally, check the content hashes (slow). */
|
/* Optionally, check the content hashes (slow). */
|
||||||
if (checkContents) {
|
if (checkContents) {
|
||||||
|
@ -1595,19 +1595,12 @@ bool LocalStore::verifyStore(bool checkContents, RepairFlag repair)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LocalStore::verifyPath(const Path & pathS, const StringSet & store,
|
void LocalStore::verifyPath(const StorePath & path, const StringSet & store,
|
||||||
PathSet & done, StorePathSet & validPaths, RepairFlag repair, bool & errors)
|
StorePathSet & done, StorePathSet & validPaths, RepairFlag repair, bool & errors)
|
||||||
{
|
{
|
||||||
checkInterrupt();
|
checkInterrupt();
|
||||||
|
|
||||||
if (!done.insert(pathS).second) return;
|
if (!done.insert(path).second) return;
|
||||||
|
|
||||||
if (!isStorePath(pathS)) {
|
|
||||||
printError("path '%s' is not in the Nix store", pathS);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto path = parseStorePath(pathS);
|
|
||||||
|
|
||||||
if (!store.count(std::string(path.to_string()))) {
|
if (!store.count(std::string(path.to_string()))) {
|
||||||
/* Check any referrers first. If we can invalidate them
|
/* Check any referrers first. If we can invalidate them
|
||||||
|
@ -1616,11 +1609,13 @@ void LocalStore::verifyPath(const Path & pathS, const StringSet & store,
|
||||||
StorePathSet referrers; queryReferrers(path, referrers);
|
StorePathSet referrers; queryReferrers(path, referrers);
|
||||||
for (auto & i : referrers)
|
for (auto & i : referrers)
|
||||||
if (i != path) {
|
if (i != path) {
|
||||||
verifyPath(printStorePath(i), store, done, validPaths, repair, errors);
|
verifyPath(i, store, done, validPaths, repair, errors);
|
||||||
if (validPaths.count(i))
|
if (validPaths.count(i))
|
||||||
canInvalidate = false;
|
canInvalidate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto pathS = printStorePath(path);
|
||||||
|
|
||||||
if (canInvalidate) {
|
if (canInvalidate) {
|
||||||
printInfo("path '%s' disappeared, removing from database...", pathS);
|
printInfo("path '%s' disappeared, removing from database...", pathS);
|
||||||
auto state(_state.lock());
|
auto state(_state.lock());
|
||||||
|
|
|
@ -314,8 +314,8 @@ private:
|
||||||
*/
|
*/
|
||||||
void invalidatePathChecked(const StorePath & path);
|
void invalidatePathChecked(const StorePath & path);
|
||||||
|
|
||||||
void verifyPath(const Path & path, const StringSet & store,
|
void verifyPath(const StorePath & path, const StringSet & store,
|
||||||
PathSet & done, StorePathSet & validPaths, RepairFlag repair, bool & errors);
|
StorePathSet & done, StorePathSet & validPaths, RepairFlag repair, bool & errors);
|
||||||
|
|
||||||
std::shared_ptr<const ValidPathInfo> queryPathInfoInternal(State & state, const StorePath & path);
|
std::shared_ptr<const ValidPathInfo> queryPathInfoInternal(State & state, const StorePath & path);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue