1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-08 19:46:02 +01:00

Merge pull request #14270 from NixOS/use-optional-storepath-serializer

Use serializer for std::optional<StorePath>
This commit is contained in:
Eelco Dolstra 2025-10-16 19:07:07 +00:00 committed by GitHub
commit a7991d55cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -251,11 +251,10 @@ void WorkerProto::Serialise<ValidPathInfo>::write(
UnkeyedValidPathInfo WorkerProto::Serialise<UnkeyedValidPathInfo>::read(const StoreDirConfig & store, ReadConn conn) UnkeyedValidPathInfo WorkerProto::Serialise<UnkeyedValidPathInfo>::read(const StoreDirConfig & store, ReadConn conn)
{ {
auto deriver = readString(conn.from); auto deriver = WorkerProto::Serialise<std::optional<StorePath>>::read(store, conn);
auto narHash = Hash::parseAny(readString(conn.from), HashAlgorithm::SHA256); auto narHash = Hash::parseAny(readString(conn.from), HashAlgorithm::SHA256);
UnkeyedValidPathInfo info(narHash); UnkeyedValidPathInfo info(narHash);
if (deriver != "") info.deriver = std::move(deriver);
info.deriver = store.parseStorePath(deriver);
info.references = WorkerProto::Serialise<StorePathSet>::read(store, conn); info.references = WorkerProto::Serialise<StorePathSet>::read(store, conn);
conn.from >> info.registrationTime >> info.narSize; conn.from >> info.registrationTime >> info.narSize;
if (GET_PROTOCOL_MINOR(conn.version) >= 16) { if (GET_PROTOCOL_MINOR(conn.version) >= 16) {
@ -269,8 +268,8 @@ UnkeyedValidPathInfo WorkerProto::Serialise<UnkeyedValidPathInfo>::read(const St
void WorkerProto::Serialise<UnkeyedValidPathInfo>::write( void WorkerProto::Serialise<UnkeyedValidPathInfo>::write(
const StoreDirConfig & store, WriteConn conn, const UnkeyedValidPathInfo & pathInfo) const StoreDirConfig & store, WriteConn conn, const UnkeyedValidPathInfo & pathInfo)
{ {
conn.to << (pathInfo.deriver ? store.printStorePath(*pathInfo.deriver) : "") WorkerProto::write(store, conn, pathInfo.deriver);
<< pathInfo.narHash.to_string(HashFormat::Base16, false); conn.to << pathInfo.narHash.to_string(HashFormat::Base16, false);
WorkerProto::write(store, conn, pathInfo.references); WorkerProto::write(store, conn, pathInfo.references);
conn.to << pathInfo.registrationTime << pathInfo.narSize; conn.to << pathInfo.registrationTime << pathInfo.narSize;
if (GET_PROTOCOL_MINOR(conn.version) >= 16) { if (GET_PROTOCOL_MINOR(conn.version) >= 16) {