aboutsummaryrefslogtreecommitdiff
path: root/src/libutil
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-05-15 17:13:45 +0200
committereldritch horrors <pennae@lix.systems>2024-07-11 20:37:27 +0000
commita5d431a9119c2560608768d9ec70fa37d5a6a985 (patch)
tree57a0b16585bb0070004cf45f537e1d87ba284960 /src/libutil
parent03db4efab90b72c15cb5513debb3ad1563e70cf7 (diff)
libstore: turn copyNAR into a generator
Change-Id: Id452f6a03faa1037ff13af0f63e32883966ff40d
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/archive.cc8
-rw-r--r--src/libutil/archive.hh4
2 files changed, 5 insertions, 7 deletions
diff --git a/src/libutil/archive.cc b/src/libutil/archive.cc
index 1b8038649..1c82c3f78 100644
--- a/src/libutil/archive.cc
+++ b/src/libutil/archive.cc
@@ -413,16 +413,14 @@ void restorePath(const Path & path, Source & source)
}
-void copyNAR(Source & source, Sink & sink)
+WireFormatGenerator copyNAR(Source & source)
{
// FIXME: if 'source' is the output of dumpPath() followed by EOF,
// we should just forward all data directly without parsing.
- ParseSink parseSink; /* null sink; just parse the NAR */
+ static ParseSink parseSink; /* null sink; just parse the NAR */
- TeeSource wrapper { source, sink };
-
- parseDump(parseSink, wrapper);
+ return parseAndCopyDump(parseSink, source);
}
diff --git a/src/libutil/archive.hh b/src/libutil/archive.hh
index 9b4ad9faf..97d99f2f4 100644
--- a/src/libutil/archive.hh
+++ b/src/libutil/archive.hh
@@ -122,9 +122,9 @@ void parseDump(ParseSink & sink, Source & source);
void restorePath(const Path & path, Source & source);
/**
- * Read a NAR from 'source' and write it to 'sink'.
+ * Read a NAR from 'source' and return it as a generator.
*/
-void copyNAR(Source & source, Sink & sink);
+WireFormatGenerator copyNAR(Source & source);
inline constexpr std::string_view narVersionMagic1 = "nix-archive-1";