diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-07-20 18:55:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-20 18:55:05 +0200 |
commit | 1c5f8bbfb5a5d55398823bb5d8a576a864cd1828 (patch) | |
tree | ae06246775d32b4cc9f96ece77eca2f9a188d491 /src/libutil | |
parent | a79b6ddaa5dd5960da845d1b8d3c80601cd918a4 (diff) | |
parent | ac2fc7ba1fe6b64ec535e4ce63d13fcadf7fdba7 (diff) |
Merge pull request #3822 from obsidiansystems/dump-thrice-fixme
Optimize `addToStoreSlow` and remove `TeeParseSink`
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/archive.hh | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/libutil/archive.hh b/src/libutil/archive.hh index 302b1bb18..57780d16a 100644 --- a/src/libutil/archive.hh +++ b/src/libutil/archive.hh @@ -63,12 +63,29 @@ struct ParseSink virtual void createSymlink(const Path & path, const string & target) { }; }; -struct TeeParseSink : ParseSink +/* If the NAR archive contains a single file at top-level, then save + the contents of the file to `s'. Otherwise barf. */ +struct RetrieveRegularNARSink : ParseSink { - StringSink saved; - TeeSource source; + bool regular = true; + Sink & sink; - TeeParseSink(Source & source) : source(source, saved) { } + RetrieveRegularNARSink(Sink & sink) : sink(sink) { } + + void createDirectory(const Path & path) + { + regular = false; + } + + void receiveContents(unsigned char * data, unsigned int len) + { + sink(data, len); + } + + void createSymlink(const Path & path, const string & target) + { + regular = false; + } }; void parseDump(ParseSink & sink, Source & source); |