daemon: Raise an error if substituter doesn't send the expected hash.

It was already impossible in practice for 'expectedHashStr' to be empty
if 'status' == "success".

* nix/libstore/build.cc (SubstitutionGoal::finished): Throw 'SubstError'
when 'expectedHashStr' is empty.
This commit is contained in:
Ludovic Courtès 2020-12-03 09:44:22 +01:00
parent 5ff521452b
commit bfe4cdf88e
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -3040,10 +3040,12 @@ void SubstitutionGoal::finished()
if (!pathExists(destPath))
throw SubstError(format("substitute did not produce path `%1%'") % destPath);
if (expectedHashStr == "")
throw SubstError(format("substituter did not communicate hash for `%1'") % storePath);
hash = hashPath(htSHA256, destPath);
/* Verify the expected hash we got from the substituer. */
if (expectedHashStr != "") {
size_t n = expectedHashStr.find(':');
if (n == string::npos)
throw Error(format("bad hash from substituter: %1%") % expectedHashStr);
@ -3060,7 +3062,6 @@ void SubstitutionGoal::finished()
% printHash16or32(actualHash));
throw SubstError(format("hash mismatch for substituted item `%1%'") % storePath);
}
}
} catch (SubstError & e) {