diff options
Diffstat (limited to 'src/libstore/store-api.cc')
-rw-r--r-- | src/libstore/store-api.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index 0f250a3c7c04..1a13e7ca32eb 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -258,6 +258,37 @@ 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); + } +} + + ValidPathInfo decodeValidPathInfo(std::istream & str, bool hashGiven) { ValidPathInfo info; |