Skip to content

Commit a7991d5

Browse files
authored
Merge pull request #14270 from NixOS/use-optional-storepath-serializer
Use serializer for std::optional<StorePath>
2 parents f84b336 + a48a737 commit a7991d5

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/libstore/worker-protocol.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,10 @@ void WorkerProto::Serialise<ValidPathInfo>::write(
251251

252252
UnkeyedValidPathInfo WorkerProto::Serialise<UnkeyedValidPathInfo>::read(const StoreDirConfig & store, ReadConn conn)
253253
{
254-
auto deriver = readString(conn.from);
254+
auto deriver = WorkerProto::Serialise<std::optional<StorePath>>::read(store, conn);
255255
auto narHash = Hash::parseAny(readString(conn.from), HashAlgorithm::SHA256);
256256
UnkeyedValidPathInfo info(narHash);
257-
if (deriver != "")
258-
info.deriver = store.parseStorePath(deriver);
257+
info.deriver = std::move(deriver);
259258
info.references = WorkerProto::Serialise<StorePathSet>::read(store, conn);
260259
conn.from >> info.registrationTime >> info.narSize;
261260
if (GET_PROTOCOL_MINOR(conn.version) >= 16) {
@@ -269,8 +268,8 @@ UnkeyedValidPathInfo WorkerProto::Serialise<UnkeyedValidPathInfo>::read(const St
269268
void WorkerProto::Serialise<UnkeyedValidPathInfo>::write(
270269
const StoreDirConfig & store, WriteConn conn, const UnkeyedValidPathInfo & pathInfo)
271270
{
272-
conn.to << (pathInfo.deriver ? store.printStorePath(*pathInfo.deriver) : "")
273-
<< pathInfo.narHash.to_string(HashFormat::Base16, false);
271+
WorkerProto::write(store, conn, pathInfo.deriver);
272+
conn.to << pathInfo.narHash.to_string(HashFormat::Base16, false);
274273
WorkerProto::write(store, conn, pathInfo.references);
275274
conn.to << pathInfo.registrationTime << pathInfo.narSize;
276275
if (GET_PROTOCOL_MINOR(conn.version) >= 16) {

0 commit comments

Comments
 (0)