* Support queryDeriver() in multi-user installations.
This commit is contained in:
parent
9d9e1c5c41
commit
6d1a1191b0
10 changed files with 42 additions and 16 deletions
|
@ -1065,7 +1065,7 @@ static string makeValidityRegistration(const PathSet & paths,
|
|||
for (PathSet::iterator i = paths.begin(); i != paths.end(); ++i) {
|
||||
s += *i + "\n";
|
||||
|
||||
Path deriver = showDerivers ? queryDeriver(noTxn, *i) : "";
|
||||
Path deriver = showDerivers ? store->queryDeriver(*i) : "";
|
||||
s += deriver + "\n";
|
||||
|
||||
PathSet references;
|
||||
|
|
|
@ -482,7 +482,7 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
|
|||
/* Note that the deriver need not be valid (e.g., if we
|
||||
previously ran the collector with `gcKeepDerivations'
|
||||
turned off). */
|
||||
Path deriver = queryDeriver(noTxn, *i);
|
||||
Path deriver = store->queryDeriver(*i);
|
||||
if (deriver != "" && store->isValidPath(deriver))
|
||||
computeFSClosure(deriver, livePaths);
|
||||
}
|
||||
|
|
|
@ -399,7 +399,7 @@ void setDeriver(const Transaction & txn, const Path & storePath,
|
|||
}
|
||||
|
||||
|
||||
Path queryDeriver(const Transaction & txn, const Path & storePath)
|
||||
static Path queryDeriver(const Transaction & txn, const Path & storePath)
|
||||
{
|
||||
if (!isRealisablePath(txn, storePath))
|
||||
throw Error(format("path `%1%' is not valid") % storePath);
|
||||
|
@ -411,6 +411,12 @@ Path queryDeriver(const Transaction & txn, const Path & storePath)
|
|||
}
|
||||
|
||||
|
||||
Path LocalStore::queryDeriver(const Path & path)
|
||||
{
|
||||
return nix::queryDeriver(noTxn, path);
|
||||
}
|
||||
|
||||
|
||||
const int substituteVersion = 2;
|
||||
|
||||
|
||||
|
@ -756,7 +762,7 @@ void LocalStore::exportPath(const Path & path, bool sign,
|
|||
nix::queryReferences(txn, path, references);
|
||||
writeStringSet(references, hashAndWriteSink);
|
||||
|
||||
Path deriver = queryDeriver(txn, path);
|
||||
Path deriver = nix::queryDeriver(txn, path);
|
||||
writeString(deriver, hashAndWriteSink);
|
||||
|
||||
if (sign) {
|
||||
|
|
|
@ -49,6 +49,8 @@ public:
|
|||
|
||||
void queryReferrers(const Path & path, PathSet & referrers);
|
||||
|
||||
Path queryDeriver(const Path & path);
|
||||
|
||||
Path addToStore(const Path & srcPath, bool fixed = false,
|
||||
bool recursive = false, string hashAlgo = "",
|
||||
PathFilter & filter = defaultPathFilter);
|
||||
|
@ -136,10 +138,6 @@ void setReferences(const Transaction & txn, const Path & path,
|
|||
void setDeriver(const Transaction & txn, const Path & path,
|
||||
const Path & deriver);
|
||||
|
||||
/* Query the deriver of a store path. Return the empty string if no
|
||||
deriver has been set. */
|
||||
Path queryDeriver(const Transaction & txn, const Path & path);
|
||||
|
||||
/* Delete a value from the nixStore directory. */
|
||||
void deleteFromStore(const Path & path, unsigned long long & bytesFreed);
|
||||
|
||||
|
|
|
@ -212,6 +212,15 @@ void RemoteStore::queryReferrers(const Path & path,
|
|||
}
|
||||
|
||||
|
||||
Path RemoteStore::queryDeriver(const Path & path)
|
||||
{
|
||||
writeInt(wopQueryDeriver, to);
|
||||
writeString(path, to);
|
||||
processStderr();
|
||||
return readStorePath(from);
|
||||
}
|
||||
|
||||
|
||||
Path RemoteStore::addToStore(const Path & _srcPath, bool fixed,
|
||||
bool recursive, string hashAlgo, PathFilter & filter)
|
||||
{
|
||||
|
@ -224,8 +233,7 @@ Path RemoteStore::addToStore(const Path & _srcPath, bool fixed,
|
|||
writeString(hashAlgo, to);
|
||||
dumpPath(srcPath, to, filter);
|
||||
processStderr();
|
||||
Path path = readStorePath(from);
|
||||
return path;
|
||||
return readStorePath(from);
|
||||
}
|
||||
|
||||
|
||||
|
@ -238,8 +246,7 @@ Path RemoteStore::addTextToStore(const string & suffix, const string & s,
|
|||
writeStringSet(references, to);
|
||||
|
||||
processStderr();
|
||||
Path path = readStorePath(from);
|
||||
return path;
|
||||
return readStorePath(from);
|
||||
}
|
||||
|
||||
|
||||
|
@ -261,8 +268,7 @@ Path RemoteStore::importPath(bool requireSignature, Source & source)
|
|||
anyway. */
|
||||
|
||||
processStderr(0, &source);
|
||||
Path path = readStorePath(from);
|
||||
return path;
|
||||
return readStorePath(from);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -37,6 +37,8 @@ public:
|
|||
|
||||
void queryReferrers(const Path & path, PathSet & referrers);
|
||||
|
||||
Path queryDeriver(const Path & path);
|
||||
|
||||
Path addToStore(const Path & srcPath, bool fixed = false,
|
||||
bool recursive = false, string hashAlgo = "",
|
||||
PathFilter & filter = defaultPathFilter);
|
||||
|
|
|
@ -77,6 +77,10 @@ public:
|
|||
virtual void queryReferrers(const Path & path,
|
||||
PathSet & referrers) = 0;
|
||||
|
||||
/* Query the deriver of a store path. Return the empty string if
|
||||
no deriver has been set. */
|
||||
virtual Path queryDeriver(const Path & path) = 0;
|
||||
|
||||
/* Copy the contents of a path to the store and register the
|
||||
validity the resulting path. The resulting path is returned.
|
||||
If `fixed' is true, then the output of a fixed-output
|
||||
|
|
|
@ -28,6 +28,7 @@ typedef enum {
|
|||
wopCollectGarbage,
|
||||
wopExportPath,
|
||||
wopImportPath,
|
||||
wopQueryDeriver,
|
||||
} WorkerOp;
|
||||
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ static Path fixPath(Path path)
|
|||
static Path useDeriver(Path path)
|
||||
{
|
||||
if (!isDerivation(path)) {
|
||||
path = queryDeriver(noTxn, path);
|
||||
path = store->queryDeriver(path);
|
||||
if (path == "")
|
||||
throw Error(format("deriver of path `%1%' is not known") % path);
|
||||
}
|
||||
|
@ -330,7 +330,7 @@ static void opQuery(Strings opFlags, Strings opArgs)
|
|||
for (Strings::iterator i = opArgs.begin();
|
||||
i != opArgs.end(); ++i)
|
||||
{
|
||||
Path deriver = queryDeriver(noTxn, fixPath(*i));
|
||||
Path deriver = store->queryDeriver(fixPath(*i));
|
||||
cout << format("%1%\n") %
|
||||
(deriver == "" ? "unknown-deriver" : deriver);
|
||||
}
|
||||
|
|
|
@ -277,6 +277,15 @@ static void performOp(Source & from, Sink & to, unsigned int op)
|
|||
break;
|
||||
}
|
||||
|
||||
case wopQueryDeriver: {
|
||||
Path path = readStorePath(from);
|
||||
startWork();
|
||||
Path deriver = store->queryDeriver(path);
|
||||
stopWork();
|
||||
writeString(deriver, to);
|
||||
break;
|
||||
}
|
||||
|
||||
case wopAddToStore: {
|
||||
/* !!! uberquick hack */
|
||||
string baseName = readString(from);
|
||||
|
|
Loading…
Reference in a new issue