aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/local-store.cc
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2023-07-31 12:22:06 -0400
committerJohn Ericson <John.Ericson@Obsidian.Systems>2023-07-31 12:44:27 -0400
commit6525265f4640221efb0039ddbd6849a3b04babc9 (patch)
tree00c4d29f72f19da7e50c33b2cb32c220ef3adc1a /src/libstore/local-store.cc
parent2a5f5fbb1776f5086646407e5296c372321863b9 (diff)
`LocalStore::verifyPath`: Try to clarify data flow with more scopes
It was initially unclear to me which of these are temporary state for the verify paths computation, and which of these are the results of that computation to be used in the rest of the function. Now, it is clear, and enforced.
Diffstat (limited to 'src/libstore/local-store.cc')
-rw-r--r--src/libstore/local-store.cc27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index 9049f33aa..17e2ebc38 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -1499,21 +1499,24 @@ bool LocalStore::verifyStore(bool checkContents, RepairFlag repair)
auto fdGCLock = openGCLock();
FdLock gcLock(fdGCLock.get(), ltRead, true, "waiting for the big garbage collector lock...");
- StorePathSet store;
- for (auto & i : readDirectory(realStoreDir)) {
- try {
- store.insert({i.name});
- } catch (BadStorePath &) { }
- }
+ StorePathSet validPaths;
- /* Check whether all valid paths actually exist. */
- printInfo("checking path existence...");
+ {
+ StorePathSet store;
+ for (auto & i : readDirectory(realStoreDir)) {
+ try {
+ store.insert({i.name});
+ } catch (BadStorePath &) { }
+ }
- StorePathSet validPaths;
- StorePathSet done;
+ /* Check whether all valid paths actually exist. */
+ printInfo("checking path existence...");
- for (auto & i : queryAllValidPaths())
- verifyPath(i, store, done, validPaths, repair, errors);
+ StorePathSet done;
+
+ for (auto & i : queryAllValidPaths())
+ verifyPath(i, store, done, validPaths, repair, errors);
+ }
/* Optionally, check the content hashes (slow). */
if (checkContents) {