about summary refs log tree commit diff
path: root/src/libstore/local-store.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2009-04-21T11·06+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2009-04-21T11·06+0000
commit8f1bf28505e6ba8fae35859391cbab7264b0014a (patch)
tree2532cf8a34d70983ca9a1b3c51f29e4d45811e3e /src/libstore/local-store.cc
parent4e646b0ddb81e1fbf1159ad66a41de848fe93930 (diff)
* nix-store --verify: don't bail out if a referenced path is missing.
  (It can't fix it though.)

Diffstat (limited to 'src/libstore/local-store.cc')
-rw-r--r--src/libstore/local-store.cc27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index 205ee3c25d..dd83e72083 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -1004,7 +1004,7 @@ void LocalStore::verifyStore(bool checkContents)
 
     PathSet validPaths2 = queryValidPaths(), validPaths;
     
-    for (PathSet::iterator i = validPaths2.begin(); i != validPaths2.end(); ++i) {
+    foreach (PathSet::iterator, i, validPaths2) {
         checkInterrupt();
         if (!isStorePath(*i)) {
             printMsg(lvlError, format("path `%1%' is not in the Nix store") % *i);
@@ -1022,26 +1022,25 @@ void LocalStore::verifyStore(bool checkContents)
 
     std::map<Path, PathSet> referrersCache;
     
-    for (PathSet::iterator i = validPaths.begin(); i != validPaths.end(); ++i) {
+    foreach (PathSet::iterator, i, validPaths) {
         bool update = false;
         ValidPathInfo info = queryPathInfo(*i, true);
 
         /* Check the references: each reference should be valid, and
            it should have a matching referrer. */
-        for (PathSet::iterator j = info.references.begin();
-             j != info.references.end(); ++j)
-        {
-            if (referrersCache.find(*j) == referrersCache.end())
-                queryReferrers(*j, referrersCache[*j]);
-            if (referrersCache[*j].find(*i) == referrersCache[*j].end()) {
-                printMsg(lvlError, format("adding missing referrer mapping from `%1%' to `%2%'")
-                    % *j % *i);
-                appendReferrer(*j, *i, true);
-            }
+        foreach (PathSet::iterator, j, info.references) {
             if (validPaths.find(*j) == validPaths.end()) {
                 printMsg(lvlError, format("incomplete closure: `%1%' needs missing `%2%'")
                     % *i % *j);
                 /* nothing we can do about it... */
+            } else {
+                if (referrersCache.find(*j) == referrersCache.end())
+                    queryReferrers(*j, referrersCache[*j]);
+                if (referrersCache[*j].find(*i) == referrersCache[*j].end()) {
+                    printMsg(lvlError, format("adding missing referrer mapping from `%1%' to `%2%'")
+                        % *j % *i);
+                    appendReferrer(*j, *i, true);
+                }
             }
         }
 
@@ -1079,7 +1078,7 @@ void LocalStore::verifyStore(bool checkContents)
     std::map<Path, PathSet> referencesCache;
     
     Strings entries = readDirectory(nixDBPath + "/referrer");
-    for (Strings::iterator i = entries.begin(); i != entries.end(); ++i) {
+    foreach (Strings::iterator, i, entries) {
         Path from = nixStore + "/" + *i;
         
         if (validPaths.find(from) == validPaths.end()) {
@@ -1103,7 +1102,7 @@ void LocalStore::verifyStore(bool checkContents)
 
         /* Each referrer should have a matching reference. */
         PathSet referrersNew;
-        for (PathSet::iterator j = referrers.begin(); j != referrers.end(); ++j) {
+        foreach (PathSet::iterator, j, referrers) {
             if (referencesCache.find(*j) == referencesCache.end())
                 queryReferences(*j, referencesCache[*j]);
             if (referencesCache[*j].find(from) == referencesCache[*j].end()) {