forked from lix-project/lix
* 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.
This commit is contained in:
parent
2398af13c5
commit
6199f9b93e
|
@ -329,6 +329,8 @@ void LocalStore::openDB(bool create)
|
||||||
"select time from FailedPaths where path = ?;");
|
"select time from FailedPaths where path = ?;");
|
||||||
stmtQueryFailedPaths.create(db,
|
stmtQueryFailedPaths.create(db,
|
||||||
"select path from FailedPaths;");
|
"select path from FailedPaths;");
|
||||||
|
stmtClearFailedPath.create(db,
|
||||||
|
"delete from FailedPaths where ?1 = '*' or path = ?1;");
|
||||||
stmtAddDerivationOutput.create(db,
|
stmtAddDerivationOutput.create(db,
|
||||||
"insert or replace into DerivationOutputs (drv, id, path) values (?, ?, ?);");
|
"insert or replace into DerivationOutputs (drv, id, path) values (?, ?, ?);");
|
||||||
stmtQueryValidDerivers.create(db,
|
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)
|
Hash parseHashField(const Path & path, const string & s)
|
||||||
{
|
{
|
||||||
string::size_type colon = s.find(':');
|
string::size_type colon = s.find(':');
|
||||||
|
|
|
@ -187,6 +187,10 @@ public:
|
||||||
/* Return the set of paths that have failed to build.*/
|
/* Return the set of paths that have failed to build.*/
|
||||||
PathSet queryFailedPaths();
|
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:
|
private:
|
||||||
|
|
||||||
Path schemaPath;
|
Path schemaPath;
|
||||||
|
@ -207,6 +211,7 @@ private:
|
||||||
SQLiteStmt stmtRegisterFailedPath;
|
SQLiteStmt stmtRegisterFailedPath;
|
||||||
SQLiteStmt stmtHasPathFailed;
|
SQLiteStmt stmtHasPathFailed;
|
||||||
SQLiteStmt stmtQueryFailedPaths;
|
SQLiteStmt stmtQueryFailedPaths;
|
||||||
|
SQLiteStmt stmtClearFailedPath;
|
||||||
SQLiteStmt stmtAddDerivationOutput;
|
SQLiteStmt stmtAddDerivationOutput;
|
||||||
SQLiteStmt stmtQueryValidDerivers;
|
SQLiteStmt stmtQueryValidDerivers;
|
||||||
SQLiteStmt stmtQueryDerivationOutputs;
|
SQLiteStmt stmtQueryDerivationOutputs;
|
||||||
|
|
|
@ -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
|
/* Scan the arguments; find the operation, set global flags, put all
|
||||||
other flags in a list, and put all other arguments in another
|
other flags in a list, and put all other arguments in another
|
||||||
list. */
|
list. */
|
||||||
|
@ -729,6 +737,8 @@ void run(Strings args)
|
||||||
op = opOptimise;
|
op = opOptimise;
|
||||||
else if (arg == "--query-failed-paths")
|
else if (arg == "--query-failed-paths")
|
||||||
op = opQueryFailedPaths;
|
op = opQueryFailedPaths;
|
||||||
|
else if (arg == "--clear-failed-paths")
|
||||||
|
op = opClearFailedPaths;
|
||||||
else if (arg == "--add-root") {
|
else if (arg == "--add-root") {
|
||||||
if (i == args.end())
|
if (i == args.end())
|
||||||
throw UsageError("`--add-root requires an argument");
|
throw UsageError("`--add-root requires an argument");
|
||||||
|
|
Loading…
Reference in a new issue