From 0bc8aedd55c85fe4960c79f9a43f746e269a760b Mon Sep 17 00:00:00 2001 From: Fedor Gogolev Date: Thu, 8 May 2014 15:02:55 +0400 Subject: [PATCH] Write stream identifier chunk even for empty input MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit «The stream identifier is always the first element in the stream.» according to «Snappy framing format description». --- snappy.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/snappy.py b/snappy.py index bf22536..0dc54ec 100644 --- a/snappy.py +++ b/snappy.py @@ -267,10 +267,9 @@ def stream_compress(src, dst, blocksize=_STREAM_TO_STREAM_BLOCK_SIZE): """ compressor = StreamCompressor() while True: - buf = src.read(blocksize) + buf = compressor.add_chunk(src.read(blocksize)) if not buf: break - buf = compressor.add_chunk(buf) - if buf: dst.write(buf) + dst.write(buf) def stream_decompress(src, dst, blocksize=_STREAM_TO_STREAM_BLOCK_SIZE):