LocalStore::verifyPath
: Use StorePathSet
for store
local var
We don't care about non-store-paths in there (things like `.links`, are, in fact, allowed). So let's just skip them up front and be more strongly typed.
This commit is contained in:
parent
dcdd5fed74
commit
2a5f5fbb17
2 changed files with 9 additions and 5 deletions
|
@ -1499,8 +1499,12 @@ 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...");
|
||||||
|
|
||||||
StringSet store;
|
StorePathSet store;
|
||||||
for (auto & i : readDirectory(realStoreDir)) store.insert(i.name);
|
for (auto & i : readDirectory(realStoreDir)) {
|
||||||
|
try {
|
||||||
|
store.insert({i.name});
|
||||||
|
} catch (BadStorePath &) { }
|
||||||
|
}
|
||||||
|
|
||||||
/* Check whether all valid paths actually exist. */
|
/* Check whether all valid paths actually exist. */
|
||||||
printInfo("checking path existence...");
|
printInfo("checking path existence...");
|
||||||
|
@ -1595,14 +1599,14 @@ bool LocalStore::verifyStore(bool checkContents, RepairFlag repair)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LocalStore::verifyPath(const StorePath & path, const StringSet & store,
|
void LocalStore::verifyPath(const StorePath & path, const StorePathSet & store,
|
||||||
StorePathSet & done, StorePathSet & validPaths, RepairFlag repair, bool & errors)
|
StorePathSet & done, StorePathSet & validPaths, RepairFlag repair, bool & errors)
|
||||||
{
|
{
|
||||||
checkInterrupt();
|
checkInterrupt();
|
||||||
|
|
||||||
if (!done.insert(path).second) return;
|
if (!done.insert(path).second) return;
|
||||||
|
|
||||||
if (!store.count(std::string(path.to_string()))) {
|
if (!store.count(path)) {
|
||||||
/* Check any referrers first. If we can invalidate them
|
/* Check any referrers first. If we can invalidate them
|
||||||
first, then we can invalidate this path as well. */
|
first, then we can invalidate this path as well. */
|
||||||
bool canInvalidate = true;
|
bool canInvalidate = true;
|
||||||
|
|
|
@ -314,7 +314,7 @@ private:
|
||||||
*/
|
*/
|
||||||
void invalidatePathChecked(const StorePath & path);
|
void invalidatePathChecked(const StorePath & path);
|
||||||
|
|
||||||
void verifyPath(const StorePath & path, const StringSet & store,
|
void verifyPath(const StorePath & path, const StorePathSet & store,
|
||||||
StorePathSet & 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