Skip to content

Commit

Permalink
BinaryCacheStore: When adding a path, ensure the references are valid
Browse files Browse the repository at this point in the history
This prevents copying a partial closure to a binary cache.
  • Loading branch information
edolstra committed Apr 22, 2016
1 parent 21ef167 commit 0207272
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/libstore/binary-cache-store.cc
Expand Up @@ -50,6 +50,17 @@ Path BinaryCacheStore::narInfoFileFor(const Path & storePath)
void BinaryCacheStore::addToCache(const ValidPathInfo & info,
const string & nar)
{
/* Verify that all references are valid. This may do some .narinfo
reads, but typically they'll already be cached. */
for (auto & ref : info.references)
try {
if (ref != info.path)
queryPathInfo(ref);
} catch (InvalidPath &) {
throw Error(format("cannot add ‘%s’ to the binary cache because the reference ‘%s’ is not valid")
% info.path % ref);
}

auto narInfoFile = narInfoFileFor(info.path);
if (fileExists(narInfoFile)) return;

Expand Down

0 comments on commit 0207272

Please sign in to comment.