Skip to content

Commit 3e9228a

Browse files
committed
NarInfo::to_string(): Loosen fileInfo/fileSize requirements
These fields are in fact optional, and various binary cache implementations do not return them (e.g. when NARs are compressed on the fly).
1 parent b5628e9 commit 3e9228a

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/libstore/nar-info.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,12 @@ std::string NarInfo::to_string(const StoreDirConfig & store) const
113113
res += "URL: " + url + "\n";
114114
assert(compression != "");
115115
res += "Compression: " + compression + "\n";
116-
assert(fileHash && fileHash->algo == HashAlgorithm::SHA256);
117-
res += "FileHash: " + fileHash->to_string(HashFormat::Nix32, true) + "\n";
118-
res += "FileSize: " + std::to_string(fileSize) + "\n";
116+
if (fileHash) {
117+
assert(fileHash->algo == HashAlgorithm::SHA256);
118+
res += "FileHash: " + fileHash->to_string(HashFormat::Nix32, true) + "\n";
119+
}
120+
if (fileSize)
121+
res += "FileSize: " + std::to_string(fileSize) + "\n";
119122
assert(narHash.algo == HashAlgorithm::SHA256);
120123
res += "NarHash: " + narHash.to_string(HashFormat::Nix32, true) + "\n";
121124
res += "NarSize: " + std::to_string(narSize) + "\n";

0 commit comments

Comments
 (0)