forked from lix-project/lix
* Add an command `nix-store --query-failed-paths' to list the cached
failed paths (when using the `build-cache-failure' option).
This commit is contained in:
parent
d66ea83a76
commit
2398af13c5
|
@ -327,6 +327,8 @@ void LocalStore::openDB(bool create)
|
||||||
"insert into FailedPaths (path, time) values (?, ?);");
|
"insert into FailedPaths (path, time) values (?, ?);");
|
||||||
stmtHasPathFailed.create(db,
|
stmtHasPathFailed.create(db,
|
||||||
"select time from FailedPaths where path = ?;");
|
"select time from FailedPaths where path = ?;");
|
||||||
|
stmtQueryFailedPaths.create(db,
|
||||||
|
"select path from FailedPaths;");
|
||||||
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,
|
||||||
|
@ -508,6 +510,25 @@ bool LocalStore::hasPathFailed(const Path & path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PathSet LocalStore::queryFailedPaths()
|
||||||
|
{
|
||||||
|
SQLiteStmtUse use(stmtQueryFailedPaths);
|
||||||
|
|
||||||
|
PathSet res;
|
||||||
|
int r;
|
||||||
|
while ((r = sqlite3_step(stmtQueryFailedPaths)) == SQLITE_ROW) {
|
||||||
|
const char * s = (const char *) sqlite3_column_text(stmtQueryFailedPaths, 0);
|
||||||
|
assert(s);
|
||||||
|
res.insert(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (r != SQLITE_DONE)
|
||||||
|
throw SQLiteError(db, "error querying failed paths");
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
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(':');
|
||||||
|
|
|
@ -184,6 +184,9 @@ public:
|
||||||
/* Query whether `path' previously failed to build. */
|
/* Query whether `path' previously failed to build. */
|
||||||
bool hasPathFailed(const Path & path);
|
bool hasPathFailed(const Path & path);
|
||||||
|
|
||||||
|
/* Return the set of paths that have failed to build.*/
|
||||||
|
PathSet queryFailedPaths();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Path schemaPath;
|
Path schemaPath;
|
||||||
|
@ -203,6 +206,7 @@ private:
|
||||||
SQLiteStmt stmtInvalidatePath;
|
SQLiteStmt stmtInvalidatePath;
|
||||||
SQLiteStmt stmtRegisterFailedPath;
|
SQLiteStmt stmtRegisterFailedPath;
|
||||||
SQLiteStmt stmtHasPathFailed;
|
SQLiteStmt stmtHasPathFailed;
|
||||||
|
SQLiteStmt stmtQueryFailedPaths;
|
||||||
SQLiteStmt stmtAddDerivationOutput;
|
SQLiteStmt stmtAddDerivationOutput;
|
||||||
SQLiteStmt stmtQueryValidDerivers;
|
SQLiteStmt stmtQueryValidDerivers;
|
||||||
SQLiteStmt stmtQueryDerivationOutputs;
|
SQLiteStmt stmtQueryDerivationOutputs;
|
||||||
|
|
|
@ -33,7 +33,7 @@ static bool indirectRoot = false;
|
||||||
LocalStore & ensureLocalStore()
|
LocalStore & ensureLocalStore()
|
||||||
{
|
{
|
||||||
LocalStore * store2(dynamic_cast<LocalStore *>(store.get()));
|
LocalStore * store2(dynamic_cast<LocalStore *>(store.get()));
|
||||||
if (!store2) throw Error("you don't have sufficient rights to use --verify");
|
if (!store2) throw Error("you don't have sufficient rights to use this command");
|
||||||
return *store2;
|
return *store2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -651,8 +651,7 @@ static void opOptimise(Strings opFlags, Strings opArgs)
|
||||||
|
|
||||||
bool dryRun = false;
|
bool dryRun = false;
|
||||||
|
|
||||||
for (Strings::iterator i = opFlags.begin();
|
foreach (Strings::iterator, i, opFlags)
|
||||||
i != opFlags.end(); ++i)
|
|
||||||
if (*i == "--dry-run") dryRun = true;
|
if (*i == "--dry-run") dryRun = true;
|
||||||
else throw UsageError(format("unknown flag `%1%'") % *i);
|
else throw UsageError(format("unknown flag `%1%'") % *i);
|
||||||
|
|
||||||
|
@ -667,6 +666,16 @@ static void opOptimise(Strings opFlags, Strings opArgs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void opQueryFailedPaths(Strings opFlags, Strings opArgs)
|
||||||
|
{
|
||||||
|
if (!opArgs.empty() || !opFlags.empty())
|
||||||
|
throw UsageError("no arguments expected");
|
||||||
|
PathSet failed = ensureLocalStore().queryFailedPaths();
|
||||||
|
foreach (PathSet::iterator, i, failed)
|
||||||
|
cout << format("%1%\n") % *i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* 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. */
|
||||||
|
@ -718,6 +727,8 @@ void run(Strings args)
|
||||||
op = opVerify;
|
op = opVerify;
|
||||||
else if (arg == "--optimise")
|
else if (arg == "--optimise")
|
||||||
op = opOptimise;
|
op = opOptimise;
|
||||||
|
else if (arg == "--query-failed-paths")
|
||||||
|
op = opQueryFailedPaths;
|
||||||
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