1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-03 06:11:46 +02:00

Factor out ServeProto::Serialiser<UnkeyedValidPathInfo> and test

In the process, partially undo e89b5bd0bf
in that the ancient < 2.4 version is now supported again by the
serializer again. `LegacySSHStore`, instead of also asserting that the
version is at least 4, just checks that `narHash` is set.

This allows us to better test the serializer in isolation for both
versions (< 4 and >= 4).
This commit is contained in:
John Ericson 2023-12-07 10:49:29 -05:00
parent c3827ff634
commit a5521b7d94
7 changed files with 131 additions and 27 deletions

View file

@ -891,16 +891,8 @@ static void opServe(Strings opFlags, Strings opArgs)
for (auto & i : paths) {
try {
auto info = store->queryPathInfo(i);
out << store->printStorePath(info->path)
<< (info->deriver ? store->printStorePath(*info->deriver) : "");
ServeProto::write(*store, wconn, info->references);
// !!! Maybe we want compression?
out << info->narSize // downloadSize
<< info->narSize;
if (GET_PROTOCOL_MINOR(clientVersion) >= 4)
out << info->narHash.to_string(HashFormat::Nix32, true)
<< renderContentAddress(info->ca)
<< info->sigs;
out << store->printStorePath(info->path);
ServeProto::write(*store, wconn, static_cast<const UnkeyedValidPathInfo &>(*info));
} catch (InvalidPath &) {
}
}