* More operations.

This commit is contained in:
Eelco Dolstra 2006-11-30 20:45:20 +00:00
parent a711689368
commit 0263279071
3 changed files with 50 additions and 9 deletions

View File

@ -2,6 +2,7 @@
#include "util.hh" #include "util.hh"
#include "remote-store.hh" #include "remote-store.hh"
#include "worker-protocol.hh" #include "worker-protocol.hh"
#include "archive.hh"
#include <iostream> #include <iostream>
#include <unistd.h> #include <unistd.h>
@ -111,33 +112,45 @@ void RemoteStore::queryReferrers(const Path & storePath,
Path RemoteStore::addToStore(const Path & srcPath) Path RemoteStore::addToStore(const Path & srcPath)
{ {
throw Error("not implemented"); writeInt(wopAddToStore, to);
writeString(baseNameOf(srcPath), to);
dumpPath(srcPath, to);
Path path = readString(from);
return path;
} }
Path RemoteStore::addToStoreFixed(bool recursive, string hashAlgo, Path RemoteStore::addToStoreFixed(bool recursive, string hashAlgo,
const Path & srcPath) const Path & srcPath)
{ {
throw Error("not implemented"); throw Error("not implemented 4");
} }
Path RemoteStore::addTextToStore(const string & suffix, const string & s, Path RemoteStore::addTextToStore(const string & suffix, const string & s,
const PathSet & references) const PathSet & references)
{ {
throw Error("not implemented"); writeInt(wopAddTextToStore, to);
writeString(suffix, to);
writeString(s, to);
writeInt(references.size(), to);
for (PathSet::iterator i = references.begin(); i != references.end(); ++i)
writeString(*i, to);
Path path = readString(from);
return path;
} }
void RemoteStore::buildDerivations(const PathSet & drvPaths) void RemoteStore::buildDerivations(const PathSet & drvPaths)
{ {
throw Error("not implemented"); throw Error("not implemented 6");
} }
void RemoteStore::ensurePath(const Path & storePath) void RemoteStore::ensurePath(const Path & storePath)
{ {
throw Error("not implemented"); throw Error("not implemented 7");
} }

View File

@ -7,9 +7,11 @@
typedef enum { typedef enum {
wopQuit = 0, wopQuit,
wopIsValidPath = 1, wopIsValidPath,
wopQuerySubstitutes = 2, wopQuerySubstitutes,
wopAddToStore,
wopAddTextToStore,
} WorkerOp; } WorkerOp;

View File

@ -3,6 +3,7 @@
#include "util.hh" #include "util.hh"
#include "serialise.hh" #include "serialise.hh"
#include "worker-protocol.hh" #include "worker-protocol.hh"
#include "archive.hh"
using namespace nix; using namespace nix;
@ -40,8 +41,33 @@ void processConnection(Source & from, Sink & to)
break; break;
} }
case wopAddToStore: {
/* !!! uberquick hack */
string baseName = readString(from);
Path tmp = createTempDir();
Path tmp2 = tmp + "/" + baseName;
restorePath(tmp2, from);
writeString(store->addToStore(tmp2), to);
deletePath(tmp);
break;
}
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);
}
writeString(store->addTextToStore(suffix, s, refs), to);
break;
}
default: default:
throw Error("invalid operation"); throw Error(format("invalid operation %1%") % op);
} }
} while (!quit); } while (!quit);