aboutsummaryrefslogtreecommitdiff
path: root/src/libutil
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-07-10 20:58:02 +0200
committerEelco Dolstra <edolstra@gmail.com>2020-07-13 16:28:45 +0200
commitfc84c358d9e55e9ba1d939d8974f6deef629848e (patch)
treec51ed8a28bef915c55fb79e8fe61adbd553313b2 /src/libutil
parent400f1a9b59d95861b4dd171c45e2dc6cf263ab99 (diff)
Make 'nix copy' to file:// binary caches run in constant memory
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/archive.hh4
-rw-r--r--src/libutil/serialise.hh13
2 files changed, 15 insertions, 2 deletions
diff --git a/src/libutil/archive.hh b/src/libutil/archive.hh
index 768fe2536..795e9ce02 100644
--- a/src/libutil/archive.hh
+++ b/src/libutil/archive.hh
@@ -63,11 +63,11 @@ struct ParseSink
virtual void createSymlink(const Path & path, const string & target) { };
};
-struct TeeSink : ParseSink
+struct TeeParseSink : ParseSink
{
TeeSource source;
- TeeSink(Source & source) : source(source) { }
+ TeeParseSink(Source & source) : source(source) { }
};
void parseDump(ParseSink & sink, Source & source);
diff --git a/src/libutil/serialise.hh b/src/libutil/serialise.hh
index a04118512..bd651fb7d 100644
--- a/src/libutil/serialise.hh
+++ b/src/libutil/serialise.hh
@@ -166,6 +166,19 @@ struct StringSource : Source
};
+/* A sink that writes all incoming data to two other sinks. */
+struct TeeSink : Sink
+{
+ Sink & sink1, & sink2;
+ TeeSink(Sink & sink1, Sink & sink2) : sink1(sink1), sink2(sink2) { }
+ virtual void operator () (const unsigned char * data, size_t len)
+ {
+ sink1(data, len);
+ sink2(data, len);
+ }
+};
+
+
/* Adapter class of a Source that saves all data read to `s'. */
struct TeeSource : Source
{