forked from lix-project/lix
NarInfo::NarInfo(): Ensure that we get a NAR size/hash
This commit is contained in:
parent
e682a8e138
commit
ea8e8df6c7
|
@ -6,7 +6,7 @@ namespace nix {
|
||||||
NarInfo::NarInfo(const Store & store, const std::string & s, const std::string & whence)
|
NarInfo::NarInfo(const Store & store, const std::string & s, const std::string & whence)
|
||||||
{
|
{
|
||||||
auto corrupt = [&]() {
|
auto corrupt = [&]() {
|
||||||
throw Error("NAR info file ‘%1%’ is corrupt");
|
throw Error(format("NAR info file ‘%1%’ is corrupt") % whence);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto parseHashField = [&](const string & s) {
|
auto parseHashField = [&](const string & s) {
|
||||||
|
@ -73,7 +73,7 @@ NarInfo::NarInfo(const Store & store, const std::string & s, const std::string &
|
||||||
|
|
||||||
if (compression == "") compression = "bzip2";
|
if (compression == "") compression = "bzip2";
|
||||||
|
|
||||||
if (path.empty() || url.empty()) corrupt();
|
if (path.empty() || url.empty() || narSize == 0 || !narHash) corrupt();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string NarInfo::to_string() const
|
std::string NarInfo::to_string() const
|
||||||
|
|
|
@ -121,6 +121,7 @@ const string base32Chars = "0123456789abcdfghijklmnpqrsvwxyz";
|
||||||
|
|
||||||
string printHash32(const Hash & hash)
|
string printHash32(const Hash & hash)
|
||||||
{
|
{
|
||||||
|
assert(hash.type != htUnknown);
|
||||||
size_t len = hash.base32Len();
|
size_t len = hash.base32Len();
|
||||||
assert(len);
|
assert(len);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue