Fix brotli compression of files > 128 KiB

This has been broken since faa31f4084.
This commit is contained in:
Eelco Dolstra 2021-04-20 22:54:49 +02:00
parent b60b0d62d6
commit 8d651a1f68

View file

@ -28,7 +28,7 @@ struct ChunkedCompressionSink : CompressionSink
const size_t CHUNK_SIZE = sizeof(outbuf) << 2; const size_t CHUNK_SIZE = sizeof(outbuf) << 2;
while (!data.empty()) { while (!data.empty()) {
size_t n = std::min(CHUNK_SIZE, data.size()); size_t n = std::min(CHUNK_SIZE, data.size());
writeInternal(data); writeInternal(data.substr(0, n));
data.remove_prefix(n); data.remove_prefix(n);
} }
} }
@ -265,7 +265,8 @@ struct BrotliCompressionSink : ChunkedCompressionSink
} }
}; };
std::unique_ptr<Source> makeDecompressionSource(Source & prev) { std::unique_ptr<Source> makeDecompressionSource(Source & prev)
{
return std::unique_ptr<Source>(new ArchiveDecompressionSource(prev)); return std::unique_ptr<Source>(new ArchiveDecompressionSource(prev));
} }