about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2010-04-26T12·56+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2010-04-26T12·56+0000
commit6199f9b93ee234139906792c8c1b4908a35df146 (patch)
treef5ce654e0c5b309e5d81b42f75cb5fa51c10ef6e
parent2398af13c53217b5de5821bac0f0c44e9081c23d (diff)
* Added a command `nix-store --clear-failed-paths <PATHS>' to clear
  the "failed" status of the given store paths.  The special value `*'
  clears all failed paths.

-rw-r--r--src/libstore/local-store.cc17
-rw-r--r--src/libstore/local-store.hh5
-rw-r--r--src/nix-store/nix-store.cc12
3 files changed, 33 insertions, 1 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index f93ba36395ac..633b3599eb4c 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -329,6 +329,8 @@ void LocalStore::openDB(bool create)
         "select time from FailedPaths where path = ?;");
     stmtQueryFailedPaths.create(db,
         "select path from FailedPaths;");
+    stmtClearFailedPath.create(db,
+        "delete from FailedPaths where ?1 = '*' or path = ?1;");
     stmtAddDerivationOutput.create(db,
         "insert or replace into DerivationOutputs (drv, id, path) values (?, ?, ?);");
     stmtQueryValidDerivers.create(db,
@@ -529,6 +531,21 @@ PathSet LocalStore::queryFailedPaths()
 }
 
 
+void LocalStore::clearFailedPaths(const PathSet & paths)
+{
+    SQLiteTxn txn(db);
+
+    foreach (PathSet::const_iterator, i, paths) {
+        SQLiteStmtUse use(stmtClearFailedPath);
+        stmtClearFailedPath.bind(*i);
+        if (sqlite3_step(stmtClearFailedPath) != SQLITE_DONE)
+            throw SQLiteError(db, format("clearing failed path `%1%' in database") % *i);
+    }
+
+    txn.commit();
+}
+
+
 Hash parseHashField(const Path & path, const string & s)
 {
     string::size_type colon = s.find(':');
diff --git a/src/libstore/local-store.hh b/src/libstore/local-store.hh
index 70fc64fdc57f..2fd640e398c4 100644
--- a/src/libstore/local-store.hh
+++ b/src/libstore/local-store.hh
@@ -187,6 +187,10 @@ public:
     /* Return the set of paths that have failed to build.*/
     PathSet queryFailedPaths();
 
+    /* Clear the "failed" status of the given paths.  The special
+       value `*' causes all failed paths to be cleared. */
+    void clearFailedPaths(const PathSet & paths);
+
 private:
 
     Path schemaPath;
@@ -207,6 +211,7 @@ private:
     SQLiteStmt stmtRegisterFailedPath;
     SQLiteStmt stmtHasPathFailed;
     SQLiteStmt stmtQueryFailedPaths;
+    SQLiteStmt stmtClearFailedPath;
     SQLiteStmt stmtAddDerivationOutput;
     SQLiteStmt stmtQueryValidDerivers;
     SQLiteStmt stmtQueryDerivationOutputs;
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc
index 34bbbcd9f01b..148fd6add48e 100644
--- a/src/nix-store/nix-store.cc
+++ b/src/nix-store/nix-store.cc
@@ -666,7 +666,7 @@ static void opOptimise(Strings opFlags, Strings opArgs)
 }
 
 
-static  void opQueryFailedPaths(Strings opFlags, Strings opArgs)
+static void opQueryFailedPaths(Strings opFlags, Strings opArgs)
 {
     if (!opArgs.empty() || !opFlags.empty())
         throw UsageError("no arguments expected");
@@ -676,6 +676,14 @@ static  void opQueryFailedPaths(Strings opFlags, Strings opArgs)
 }
 
 
+static void opClearFailedPaths(Strings opFlags, Strings opArgs)
+{
+    if (!opFlags.empty())
+        throw UsageError("no flags expected");
+    ensureLocalStore().clearFailedPaths(PathSet(opArgs.begin(), opArgs.end()));
+}
+
+
 /* Scan the arguments; find the operation, set global flags, put all
    other flags in a list, and put all other arguments in another
    list. */
@@ -729,6 +737,8 @@ void run(Strings args)
             op = opOptimise;
         else if (arg == "--query-failed-paths")
             op = opQueryFailedPaths;
+        else if (arg == "--clear-failed-paths")
+            op = opClearFailedPaths;
         else if (arg == "--add-root") {
             if (i == args.end())
                 throw UsageError("`--add-root requires an argument");