From 6444e3894d35b7829870e666bc57e586be562555 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Thu, 27 Feb 2025 16:08:50 +0100 Subject: [PATCH] libutil: drop parseAndCopyDump with copyNAR no longer using it it doesn't have to be public any more, and since parseDump does not need to pass through its input data we'll also turn restore() into a plain function instead of a wire generator. Change-Id: Idd3a0270089ff47a7dc8ca96eb03b002fa5ea37e --- lix/libutil/archive.cc | 46 ++++++++++++------------------------------ lix/libutil/archive.hh | 1 - 2 files changed, 13 insertions(+), 34 deletions(-) diff --git a/lix/libutil/archive.cc b/lix/libutil/archive.cc index b2dcfd058..7381e37b8 100644 --- a/lix/libutil/archive.cc +++ b/lix/libutil/archive.cc @@ -370,56 +370,36 @@ Generator parse(Source & source) } -static WireFormatGenerator restore(NARParseVisitor & sink, nar::Entry entry, const Path & path) +static void restore(NARParseVisitor & sink, nar::Entry entry, const Path & path) { return std::visit( overloaded{ - [](nar::MetadataString m) -> WireFormatGenerator { - co_yield m.data; - }, - [](nar::MetadataRaw r) -> WireFormatGenerator { - co_yield r.raw; - }, + [](nar::MetadataString m) {}, + [](nar::MetadataRaw r) {}, [&](nar::File f) { auto handle = sink.createRegularFile(path, f.size, f.executable); - return [](auto handle, auto f) -> WireFormatGenerator { - while (auto block = f.contents.next()) { - handle->receiveContents(std::string_view{block->data(), block->size()}); - co_yield *block; - } - handle->close(); - }(std::move(handle), std::move(f)); - }, - [&](nar::Symlink sl) { - sink.createSymlink(path, sl.target); - return []() -> WireFormatGenerator { co_return; }(); + while (auto block = f.contents.next()) { + handle->receiveContents(std::string_view{block->data(), block->size()}); + } + handle->close(); }, + [&](nar::Symlink sl) { sink.createSymlink(path, sl.target); }, [&](nar::Directory d) { auto dir = sink.createDirectory(path); - return [](auto dir, auto d) -> WireFormatGenerator { - while (auto entry = d.contents.next()) { - co_yield restore(*dir, std::move(entry->second), entry->first); - } - }(std::move(dir), std::move(d)); + while (auto entry = d.contents.next()) { + restore(*dir, std::move(entry->second), entry->first); + } }, }, std::move(entry) ); } -WireFormatGenerator parseAndCopyDump(NARParseVisitor & sink, Source & source) +void parseDump(NARParseVisitor & sink, Source & source) { auto nar = nar::parse(source); while (auto entry = nar.next()) { - co_yield restore(sink, std::move(*entry), ""); - } -} - -void parseDump(NARParseVisitor & sink, Source & source) -{ - auto parser = parseAndCopyDump(sink, source); - while (parser.next()) { - // ignore the actual item + restore(sink, std::move(*entry), ""); } } diff --git a/lix/libutil/archive.hh b/lix/libutil/archive.hh index 574599f62..7d7d93e6c 100644 --- a/lix/libutil/archive.hh +++ b/lix/libutil/archive.hh @@ -157,7 +157,6 @@ Generator parse(Source & source); } -WireFormatGenerator parseAndCopyDump(NARParseVisitor & sink, Source & source); void parseDump(NARParseVisitor & sink, Source & source); void restorePath(const Path & path, Source & source);