mirror of
https://github.com/NixOS/nix.git
synced 2025-11-11 13:06:01 +01:00
* More remote operations.
* Added new operation hasSubstitutes(), which is more efficient than querySubstitutes().size() > 0.
This commit is contained in:
parent
aac547a8b3
commit
0565b5f2b3
12 changed files with 138 additions and 46 deletions
|
|
@ -8,6 +8,23 @@
|
|||
using namespace nix;
|
||||
|
||||
|
||||
Path readStorePath(Source & from)
|
||||
{
|
||||
Path path = readString(from);
|
||||
assertStorePath(path);
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
PathSet readStorePaths(Source & from)
|
||||
{
|
||||
PathSet paths = readStringSet(from);
|
||||
for (PathSet::iterator i = paths.begin(); i != paths.end(); ++i)
|
||||
assertStorePath(*i);
|
||||
return paths;
|
||||
}
|
||||
|
||||
|
||||
void processConnection(Source & from, Sink & to)
|
||||
{
|
||||
store = boost::shared_ptr<StoreAPI>(new LocalStore(true));
|
||||
|
|
@ -35,12 +52,29 @@ void processConnection(Source & from, Sink & to)
|
|||
break;
|
||||
|
||||
case wopIsValidPath: {
|
||||
Path path = readString(from);
|
||||
assertStorePath(path);
|
||||
Path path = readStorePath(from);
|
||||
writeInt(store->isValidPath(path), to);
|
||||
break;
|
||||
}
|
||||
|
||||
case wopHasSubstitutes: {
|
||||
Path path = readStorePath(from);
|
||||
writeInt(store->hasSubstitutes(path), to);
|
||||
break;
|
||||
}
|
||||
|
||||
case wopQueryReferences:
|
||||
case wopQueryReferrers: {
|
||||
Path path = readStorePath(from);
|
||||
PathSet paths;
|
||||
if (op == wopQueryReferences)
|
||||
store->queryReferences(path, paths);
|
||||
else
|
||||
store->queryReferrers(path, paths);
|
||||
writeStringSet(paths, to);
|
||||
break;
|
||||
}
|
||||
|
||||
case wopAddToStore: {
|
||||
/* !!! uberquick hack */
|
||||
string baseName = readString(from);
|
||||
|
|
@ -55,17 +89,25 @@ void processConnection(Source & from, Sink & to)
|
|||
case wopAddTextToStore: {
|
||||
string suffix = readString(from);
|
||||
string s = readString(from);
|
||||
unsigned int refCount = readInt(from);
|
||||
PathSet refs;
|
||||
while (refCount--) {
|
||||
Path ref = readString(from);
|
||||
assertStorePath(ref);
|
||||
refs.insert(ref);
|
||||
}
|
||||
PathSet refs = readStorePaths(from);
|
||||
writeString(store->addTextToStore(suffix, s, refs), to);
|
||||
break;
|
||||
}
|
||||
|
||||
case wopBuildDerivations: {
|
||||
PathSet drvs = readStorePaths(from);
|
||||
store->buildDerivations(drvs);
|
||||
writeInt(1, to);
|
||||
break;
|
||||
}
|
||||
|
||||
case wopEnsurePath: {
|
||||
Path path = readStorePath(from);
|
||||
store->ensurePath(path);
|
||||
writeInt(1, to);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
throw Error(format("invalid operation %1%") % op);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue