LocalStore::addToStore: Throw an exception if no hash is given

This commit is contained in:
Eelco Dolstra 2018-03-26 23:34:25 +02:00
parent 3cab639e21
commit 23d6bb583a
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE

View file

@ -976,7 +976,8 @@ const PublicKeys & LocalStore::getPublicKeys()
void LocalStore::addToStore(const ValidPathInfo & info, Source & source,
RepairFlag repair, CheckSigsFlag checkSigs, std::shared_ptr<FSAccessor> accessor)
{
assert(info.narHash);
if (!info.narHash)
throw Error("cannot add path '%s' because it lacks a hash", info.path);
if (requireSigs && checkSigs && !info.checkSignatures(*this, getPublicKeys()))
throw Error("cannot add path '%s' because it lacks a valid signature", info.path);