diff options
author | eldritch horrors <pennae@lix.systems> | 2024-05-18 19:24:17 +0200 |
---|---|---|
committer | eldritch horrors <pennae@lix.systems> | 2024-07-16 01:50:16 +0000 |
commit | d094dd0396a9ec0b4ce725412cc73c6d9af31021 (patch) | |
tree | 3b593d7f1e60f3acbf3629427b3800da8f75dcab /src/libstore/remote-store.cc | |
parent | 6b4d46e9e0e1dd80e0977684ab20d14bcd1a6bc3 (diff) |
libstore: remove remaining sinkToSource uses
Change-Id: Id1ee0d2ad4a3774f4bbb960d76f0f76ac4f3eff9
Diffstat (limited to 'src/libstore/remote-store.cc')
-rw-r--r-- | src/libstore/remote-store.cc | 29 |
1 files changed, 19 insertions, 10 deletions
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<ValidPathInfo>::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<ValidPathInfo>::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( |