* Allow unprivileged users to do `nix-store --clear-failed-paths' and

`nix-store --query-failed-paths'.
This commit is contained in:
Eelco Dolstra 2010-05-04 10:45:10 +00:00
parent 7fa338f4ba
commit f92c9a0ac5
7 changed files with 51 additions and 5 deletions

View file

@ -184,11 +184,8 @@ public:
/* Query whether `path' previously failed to build. */
bool hasPathFailed(const Path & path);
/* 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:

View file

@ -451,6 +451,25 @@ void RemoteStore::collectGarbage(const GCOptions & options, GCResults & results)
}
PathSet RemoteStore::queryFailedPaths()
{
openConnection();
writeInt(wopQueryFailedPaths, to);
processStderr();
return readStorePaths(from);
}
void RemoteStore::clearFailedPaths(const PathSet & paths)
{
openConnection();
writeInt(wopClearFailedPaths, to);
writeStringSet(paths, to);
processStderr();
readInt(from);
}
void RemoteStore::processStderr(Sink * sink, Source * source)
{
unsigned int msg;

View file

@ -70,6 +70,10 @@ public:
void collectGarbage(const GCOptions & options, GCResults & results);
PathSet queryFailedPaths();
void clearFailedPaths(const PathSet & paths);
private:
AutoCloseFD fdSocket;
FdSink to;

View file

@ -209,6 +209,13 @@ public:
/* Perform a garbage collection. */
virtual void collectGarbage(const GCOptions & options, GCResults & results) = 0;
/* Return the set of paths that have failed to build.*/
virtual PathSet queryFailedPaths() = 0;
/* Clear the "failed" status of the given paths. The special
value `*' causes all failed paths to be cleared. */
virtual void clearFailedPaths(const PathSet & paths) = 0;
};

View file

@ -36,6 +36,8 @@ typedef enum {
wopQuerySubstitutablePathInfo = 21,
wopQueryDerivationOutputs = 22,
wopQueryValidPaths = 23,
wopQueryFailedPaths = 24,
wopClearFailedPaths = 25,
} WorkerOp;

View file

@ -670,7 +670,7 @@ static void opQueryFailedPaths(Strings opFlags, Strings opArgs)
{
if (!opArgs.empty() || !opFlags.empty())
throw UsageError("no arguments expected");
PathSet failed = ensureLocalStore().queryFailedPaths();
PathSet failed = store->queryFailedPaths();
foreach (PathSet::iterator, i, failed)
cout << format("%1%\n") % *i;
}
@ -680,7 +680,7 @@ static void opClearFailedPaths(Strings opFlags, Strings opArgs)
{
if (!opFlags.empty())
throw UsageError("no flags expected");
ensureLocalStore().clearFailedPaths(PathSet(opArgs.begin(), opArgs.end()));
store->clearFailedPaths(PathSet(opArgs.begin(), opArgs.end()));
}

View file

@ -528,6 +528,23 @@ static void performOp(unsigned int clientVersion,
break;
}
case wopQueryFailedPaths: {
startWork();
PathSet paths = store->queryFailedPaths();
stopWork();
writeStringSet(paths, to);
break;
}
case wopClearFailedPaths: {
PathSet paths = readStringSet(from);
startWork();
store->clearFailedPaths(paths);
stopWork();
writeInt(1, to);
break;
}
default:
throw Error(format("invalid operation %1%") % op);
}