From d094dd0396a9ec0b4ce725412cc73c6d9af31021 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Sat, 18 May 2024 19:24:17 +0200 Subject: libstore: remove remaining sinkToSource uses Change-Id: Id1ee0d2ad4a3774f4bbb960d76f0f76ac4f3eff9 --- src/libstore/remote-store.cc | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'src/libstore/remote-store.cc') diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index 56b6093bc..1b0524316 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -485,17 +485,26 @@ void RemoteStore::addMultipleToStore( { auto remoteVersion = getProtocol(); - auto source = sinkToSource([&](Sink & sink) { - sink << pathsToCopy.size(); - for (auto & [pathInfo, pathSource] : pathsToCopy) { - sink << WorkerProto::Serialise::write(*this, - WorkerProto::WriteConn {remoteVersion}, - pathInfo); - pathSource->drainInto(sink); - } - }); + GeneratorSource source{ + [](auto self, auto & pathsToCopy, auto remoteVersion) -> WireFormatGenerator { + co_yield pathsToCopy.size(); + for (auto & [pathInfo, pathSource] : pathsToCopy) { + co_yield WorkerProto::Serialise::write(*self, + WorkerProto::WriteConn {remoteVersion}, + pathInfo); + try { + char buf[65536]; + while (true) { + const auto read = pathSource->read(buf, sizeof(buf)); + co_yield std::span{buf, read}; + } + } catch (EndOfFile &) { + } + } + }(this, pathsToCopy, remoteVersion) + }; - addMultipleToStore(*source, repair, checkSigs); + addMultipleToStore(source, repair, checkSigs); } void RemoteStore::addMultipleToStore( -- cgit v1.2.3