download-via-ssh: Use readStorePath

This commit is contained in:
Eelco Dolstra 2014-02-14 12:31:10 +01:00
parent 4db572062c
commit a9d99ab55f
2 changed files with 13 additions and 5 deletions

View file

@ -5,6 +5,8 @@
#include "affinity.hh" #include "affinity.hh"
#include "globals.hh" #include "globals.hh"
#include "serve-protocol.hh" #include "serve-protocol.hh"
#include "worker-protocol.hh"
#include "store-api.hh"
#include <iostream> #include <iostream>
#include <unistd.h> #include <unistd.h>
@ -82,10 +84,15 @@ static void query(std::pair<FdSink, FdSource> & pipes)
writeInt(qCmdInfo, pipes.first); writeInt(qCmdInfo, pipes.first);
writeStrings(tokenized, pipes.first); writeStrings(tokenized, pipes.first);
pipes.first.flush(); pipes.first.flush();
for (Path path = readString(pipes.second); !path.empty(); path = readString(pipes.second)) { while (1) {
Path path = readString(pipes.second);
if (path.empty()) break;
assertStorePath(path);
std::cout << path << std::endl; std::cout << path << std::endl;
std::cout << readString(pipes.second) << std::endl; string deriver = readString(pipes.second);
PathSet references = readStrings<PathSet>(pipes.second); if (!deriver.empty()) assertStorePath(deriver);
std::cout << deriver << std::endl;
PathSet references = readStorePaths<PathSet>(pipes.second);
std::cout << references.size() << std::endl; std::cout << references.size() << std::endl;
foreach (PathSet::iterator, i, references) foreach (PathSet::iterator, i, references)
std::cout << *i << std::endl; std::cout << *i << std::endl;

View file

@ -7,6 +7,7 @@
#include "local-store.hh" #include "local-store.hh"
#include "util.hh" #include "util.hh"
#include "serve-protocol.hh" #include "serve-protocol.hh"
#include "worker-protocol.hh"
#include <iostream> #include <iostream>
#include <algorithm> #include <algorithm>
@ -864,12 +865,12 @@ static void opServe(Strings opFlags, Strings opArgs)
} }
switch (qCmd) { switch (qCmd) {
case qCmdHave: { case qCmdHave: {
PathSet paths = readStrings<PathSet>(in); PathSet paths = readStorePaths<PathSet>(in);
writeStrings(store->queryValidPaths(paths), out); writeStrings(store->queryValidPaths(paths), out);
break; break;
} }
case qCmdInfo: { case qCmdInfo: {
PathSet paths = readStrings<PathSet>(in); PathSet paths = readStorePaths<PathSet>(in);
// !!! Maybe we want a queryPathInfos? // !!! Maybe we want a queryPathInfos?
foreach (PathSet::iterator, i, paths) { foreach (PathSet::iterator, i, paths) {
if (!store->isValidPath(*i)) if (!store->isValidPath(*i))