aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/store-api.cc
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2014-02-07 14:07:31 -0500
committerShea Levy <shea@shealevy.com>2014-02-08 00:13:32 -0500
commit94884475947ca8c44dda51d83f3c1fbfeff5ccc0 (patch)
tree47d7300fda3e54c874290d60a879c9d0d5708d41 /src/libstore/store-api.cc
parent3a38d0f3565a02c034c29b264aceb0eb78dac005 (diff)
nix-store --serve: Don't loop forever
nix-store --export takes a tmproot, which can only release by exiting. Substituters don't currently work in a way that could take advantage of the looping, anyway. Signed-off-by: Shea Levy <shea@shealevy.com>
Diffstat (limited to 'src/libstore/store-api.cc')
-rw-r--r--src/libstore/store-api.cc51
1 files changed, 25 insertions, 26 deletions
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc
index 1a13e7ca3..d4d53e9da 100644
--- a/src/libstore/store-api.cc
+++ b/src/libstore/store-api.cc
@@ -260,32 +260,31 @@ string StoreAPI::makeValidityRegistration(const PathSet & paths,
void StoreAPI::serve(Source & in, Sink & out, bool sign)
{
- for (string cmd = readString(in); !cmd.empty(); cmd = readString(in)) {
- if (cmd == "query") {
- for (cmd = readString(in); !cmd.empty(); cmd = readString(in)) {
- PathSet paths = readStrings<PathSet>(in);
- if (cmd == "have") {
- writeStrings(queryValidPaths(paths), out);
- } else if (cmd == "info") {
- // !!! Maybe we want a queryPathInfos?
- foreach (PathSet::iterator, i, paths) {
- ValidPathInfo info = queryPathInfo(*i);
- writeString(info.path, out);
- writeString(info.deriver, out);
- writeStrings(info.references, out);
- // !!! Maybe we want compression?
- writeLongLong(info.narSize, out); // downloadSize
- writeLongLong(info.narSize, out);
- }
- writeString("", out);
- } else
- throw Error(format("Unknown serve query `%1%'") % cmd);
- }
- } else if (cmd == "substitute")
- exportPath(readString(in), sign, out);
- else
- throw Error(format("Unknown serve command `%1%'") % cmd);
- }
+ string cmd = readString(in);
+ if (cmd == "query") {
+ for (cmd = readString(in); !cmd.empty(); cmd = readString(in)) {
+ PathSet paths = readStrings<PathSet>(in);
+ if (cmd == "have") {
+ writeStrings(queryValidPaths(paths), out);
+ } else if (cmd == "info") {
+ // !!! Maybe we want a queryPathInfos?
+ foreach (PathSet::iterator, i, paths) {
+ ValidPathInfo info = queryPathInfo(*i);
+ writeString(info.path, out);
+ writeString(info.deriver, out);
+ writeStrings(info.references, out);
+ // !!! Maybe we want compression?
+ writeLongLong(info.narSize, out); // downloadSize
+ writeLongLong(info.narSize, out);
+ }
+ writeString("", out);
+ } else
+ throw Error(format("Unknown serve query `%1%'") % cmd);
+ }
+ } else if (cmd == "substitute")
+ exportPath(readString(in), sign, out);
+ else
+ throw Error(format("Unknown serve command `%1%'") % cmd);
}