From 58846b0a1c896c55f3897f45b363ad2ba8a53ed5 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 15 Oct 2025 17:58:14 -0400 Subject: [PATCH] Deduplicate protocol code more with `ServeProto::BasicClientConnection` I did this in Nix for this purpose, but didn't get around to actually taking advantage of it here, until now. --- src/hydra-queue-runner/build-remote.cc | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/hydra-queue-runner/build-remote.cc b/src/hydra-queue-runner/build-remote.cc index b372e7dd..c0d6ff6c 100644 --- a/src/hydra-queue-runner/build-remote.cc +++ b/src/hydra-queue-runner/build-remote.cc @@ -103,9 +103,9 @@ static void copyClosureTo( std::unique_lock sendLock(conn.machine->state->sendLock, std::chrono::seconds(600)); - conn.to << ServeProto::Command::ImportPaths; - destStore.exportPaths(missing, conn.to); - conn.to.flush(); + conn.importPaths(destStore, [&](Sink & sink) { + destStore.exportPaths(missing, sink); + }); if (readInt(conn.from) != 1) throw Error("remote machine failed to import closure"); @@ -298,11 +298,10 @@ static void copyPathFromRemote( lambda function only gets executed if someone tries to read from source2, we will send the command from here rather than outside the lambda. */ - conn.to << ServeProto::Command::DumpStorePath << localStore.printStorePath(info.path); - conn.to.flush(); - - TeeSource tee(conn.from, sink); - extractNarData(tee, localStore.printStorePath(info.path), narMembers); + conn.narFromPath(localStore, info.path, [&](Source & source) { + TeeSource tee(source, sink); + extractNarData(tee, localStore.printStorePath(info.path), narMembers); + }); }); destStore.addToStore(info, *source2, NoRepair, NoCheckSigs);