diff options
author | Ben Radford <benradf@users.noreply.github.com> | 2023-07-28 10:11:45 +0100 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2023-07-31 11:17:55 -0400 |
commit | c9a87ce7ca50b0a14c4c77fd2b6ca41a74ba6cb9 (patch) | |
tree | ba4c8b75c61ac4f6c9eddfe852adce39132f0780 | |
parent | 2d1d81114d72ace89ce08cd3bc93f4eb27a2975d (diff) |
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.
-rw-r--r-- | src/libstore/local-store.cc | 21 | ||||
-rw-r--r-- | src/libstore/local-store.hh | 4 |
2 files changed, 10 insertions, 15 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index f8e0a0ca2..f78bd44ca 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -1506,10 +1506,10 @@ bool LocalStore::verifyStore(bool checkContents, RepairFlag repair) printInfo("checking path existence..."); StorePathSet validPaths; - PathSet done; + StorePathSet done; 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). */ if (checkContents) { @@ -1595,19 +1595,12 @@ bool LocalStore::verifyStore(bool checkContents, RepairFlag repair) } -void LocalStore::verifyPath(const Path & pathS, const StringSet & store, - PathSet & done, StorePathSet & validPaths, RepairFlag repair, bool & errors) +void LocalStore::verifyPath(const StorePath & path, const StringSet & store, + StorePathSet & done, StorePathSet & validPaths, RepairFlag repair, bool & errors) { checkInterrupt(); - if (!done.insert(pathS).second) return; - - if (!isStorePath(pathS)) { - printError("path '%s' is not in the Nix store", pathS); - return; - } - - auto path = parseStorePath(pathS); + if (!done.insert(path).second) return; if (!store.count(std::string(path.to_string()))) { /* 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); for (auto & i : referrers) if (i != path) { - verifyPath(printStorePath(i), store, done, validPaths, repair, errors); + verifyPath(i, store, done, validPaths, repair, errors); if (validPaths.count(i)) canInvalidate = false; } + auto pathS = printStorePath(path); + if (canInvalidate) { printInfo("path '%s' disappeared, removing from database...", pathS); auto state(_state.lock()); diff --git a/src/libstore/local-store.hh b/src/libstore/local-store.hh index 4125cacf4..c9b570eaa 100644 --- a/src/libstore/local-store.hh +++ b/src/libstore/local-store.hh @@ -314,8 +314,8 @@ private: */ void invalidatePathChecked(const StorePath & path); - void verifyPath(const Path & path, const StringSet & store, - PathSet & done, StorePathSet & validPaths, RepairFlag repair, bool & errors); + void verifyPath(const StorePath & path, const StringSet & store, + StorePathSet & done, StorePathSet & validPaths, RepairFlag repair, bool & errors); std::shared_ptr<const ValidPathInfo> queryPathInfoInternal(State & state, const StorePath & path); |