Skip to content

Commit

Permalink
Dedup more protocol code
Browse files Browse the repository at this point in the history
  • Loading branch information
Ericson2314 committed May 20, 2024
1 parent e4552dd commit 4ad4120
Showing 1 changed file with 3 additions and 27 deletions.
30 changes: 3 additions & 27 deletions src/hydra-queue-runner/build-remote.cc
Original file line number Diff line number Diff line change
Expand Up @@ -267,32 +267,6 @@ static BuildResult performBuild(
return result;
}

static std::map<StorePath, UnkeyedValidPathInfo> queryPathInfos(
::Machine::Connection & conn,
Store & localStore,
StorePathSet & outputs,
size_t & totalNarSize
)
{

/* Get info about each output path. */
std::map<StorePath, UnkeyedValidPathInfo> infos;
conn.to << ServeProto::Command::QueryPathInfos;
ServeProto::write(localStore, conn, outputs);
conn.to.flush();
while (true) {
auto storePathS = readString(conn.from);
if (storePathS == "") break;

auto storePath = localStore.parseStorePath(storePathS);
auto info = ServeProto::Serialise<UnkeyedValidPathInfo>::read(localStore, conn);
totalNarSize += info.narSize;
infos.insert_or_assign(std::move(storePath), std::move(info));
}

return infos;
}

static void copyPathFromRemote(
::Machine::Connection & conn,
NarMemberDatas & narMembers,
Expand Down Expand Up @@ -552,8 +526,10 @@ void State::buildRemote(ref<Store> destStore,

auto now1 = std::chrono::steady_clock::now();

auto infos = conn.queryPathInfos(*localStore, outputs);

size_t totalNarSize = 0;
auto infos = build_remote::queryPathInfos(conn, *localStore, outputs, totalNarSize);
for (auto & [_, info] : infos) totalNarSize += info.narSize;

if (totalNarSize > maxOutputSize) {
result.stepStatus = bsNarSizeLimitExceeded;
Expand Down

0 comments on commit 4ad4120

Please sign in to comment.