1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-26 15:51:15 +02:00

Add Store::dumpPath() method

This allows applying nix-store --verify-path to binary cache stores:

  NIX_REMOTE=https://cache.nixos.org nix-store --verify-path /nix/store/s5c7...
This commit is contained in:
Eelco Dolstra 2016-03-21 17:55:57 +01:00
parent 87295b9844
commit 1c5f73f529
7 changed files with 29 additions and 7 deletions

View file

@ -156,10 +156,8 @@ bool BinaryCacheStore::isValidPath(const Path & storePath)
return fileExists(narInfoFileFor(storePath));
}
void BinaryCacheStore::exportPath(const Path & storePath, bool sign, Sink & sink)
void BinaryCacheStore::dumpPath(const Path & storePath, Sink & sink)
{
assert(!sign);
auto res = readNarInfo(storePath);
auto nar = getFile(res.url);
@ -183,6 +181,15 @@ void BinaryCacheStore::exportPath(const Path & storePath, bool sign, Sink & sink
assert(nar.size() % 8 == 0);
sink((unsigned char *) nar.c_str(), nar.size());
}
void BinaryCacheStore::exportPath(const Path & storePath, bool sign, Sink & sink)
{
assert(!sign);
auto res = readNarInfo(storePath);
dumpPath(storePath, sink);
// FIXME: check integrity of NAR.
@ -264,7 +271,7 @@ Path BinaryCacheStore::addToStore(const string & name, const Path & srcPath,
StringSink sink;
Hash h;
if (recursive) {
dumpPath(srcPath, sink, filter);
nix::dumpPath(srcPath, sink, filter);
h = hashString(hashAlgo, *sink.s);
} else {
auto s = readFile(srcPath);