about summary refs log tree commit diff
path: root/src/nix-store
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-10-02T19·04-0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-10-02T19·12-0400
commit8e3a7bd71253f02eb1a9fbb996166727b1283887 (patch)
tree622c2de46ea29a6d42defc50b65112c5b6022138 /src/nix-store
parent9958bd6992e2b3e7bacb493a372d17d5a5b95d90 (diff)
nix-store --verify: Add an option ‘--repair’ to repair all missing/corrupt paths
Also, return a non-zero exit code if errors remain after
verifying/repairing.
Diffstat (limited to 'src/nix-store')
-rw-r--r--src/nix-store/nix-store.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc
index ce415ce4aeb1..0ed8b6d74b7c 100644
--- a/src/nix-store/nix-store.cc
+++ b/src/nix-store/nix-store.cc
@@ -703,13 +703,18 @@ static void opVerify(Strings opFlags, Strings opArgs)
         throw UsageError("no arguments expected");
 
     bool checkContents = false;
+    bool repair = false;
 
     for (Strings::iterator i = opFlags.begin();
          i != opFlags.end(); ++i)
         if (*i == "--check-contents") checkContents = true;
+        else if (*i == "--repair") repair = true;
         else throw UsageError(format("unknown flag `%1%'") % *i);
 
-    ensureLocalStore().verifyStore(checkContents);
+    if (ensureLocalStore().verifyStore(checkContents, repair)) {
+        printMsg(lvlError, "warning: not all errors were fixed");
+        exitCode = 1;
+    }
 }
 
 
@@ -743,7 +748,6 @@ static void opRepairPath(Strings opFlags, Strings opArgs)
 
     foreach (Strings::iterator, i, opArgs) {
         Path path = followLinksToStorePath(*i);
-        printMsg(lvlTalkative, format("repairing path `%1%'...") % path);
         ensureLocalStore().repairPath(path);
     }
 }