diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-08-13 17:19:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-13 17:19:50 +0200 |
commit | e11bbfb0ab0cea1b7e64cfad7704db518cb901fa (patch) | |
tree | 10388e457650366ed00a3c7f1763d10227ac40f9 /src/libstore/binary-cache-store.cc | |
parent | 859cd4acea8feadcc0b080ec1a75891e6277339c (diff) | |
parent | 85aacbee64680e60b22e8a729756b0a3882f8b8f (diff) |
Merge pull request #3928 from obsidiansystems/more-tee
Use `TeeSink` and `TeeSouce` in a few more places
Diffstat (limited to 'src/libstore/binary-cache-store.cc')
-rw-r--r-- | src/libstore/binary-cache-store.cc | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/libstore/binary-cache-store.cc b/src/libstore/binary-cache-store.cc index 86877dd1a..c360b9dda 100644 --- a/src/libstore/binary-cache-store.cc +++ b/src/libstore/binary-cache-store.cc @@ -312,14 +312,10 @@ void BinaryCacheStore::narFromPath(const StorePath & storePath, Sink & sink) { auto info = queryPathInfo(storePath).cast<const NarInfo>(); - uint64_t narSize = 0; + LengthSink narSize; + TeeSink tee { sink, narSize }; - LambdaSink wrapperSink([&](const unsigned char * data, size_t len) { - sink(data, len); - narSize += len; - }); - - auto decompressor = makeDecompressionSink(info->compression, wrapperSink); + auto decompressor = makeDecompressionSink(info->compression, tee); try { getFile(info->url, *decompressor); @@ -331,7 +327,7 @@ void BinaryCacheStore::narFromPath(const StorePath & storePath, Sink & sink) stats.narRead++; //stats.narReadCompressedBytes += nar->size(); // FIXME - stats.narReadBytes += narSize; + stats.narReadBytes += narSize.length; } void BinaryCacheStore::queryPathInfoUncached(const StorePath & storePath, |