diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-04-22T10·15+0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-04-22T10·15+0200 |
commit | 0207272b28f1dad119b418dfafcfb18d22b6d3f6 (patch) | |
tree | cf273c38481a7dcec641bac7a07161e9a9bc00f7 /src/libstore/binary-cache-store.cc | |
parent | 21ef1670b3cb592ae504cca4e412082746affcfe (diff) |
BinaryCacheStore: When adding a path, ensure the references are valid
This prevents copying a partial closure to a binary cache.
Diffstat (limited to 'src/libstore/binary-cache-store.cc')
-rw-r--r-- | src/libstore/binary-cache-store.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libstore/binary-cache-store.cc b/src/libstore/binary-cache-store.cc index 4445bfd27a12..93863b95fe7f 100644 --- a/src/libstore/binary-cache-store.cc +++ b/src/libstore/binary-cache-store.cc @@ -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; |