Skip to content

Commit

Permalink
use zstd stream reader since image may not have content size header
Browse files Browse the repository at this point in the history
Signed-off-by: Jannik Glückert <[email protected]>
Closes: #12
Signed-off-by: Michał Górny <[email protected]>
  • Loading branch information
Jannik2099 authored and mgorny committed Aug 10, 2021
1 parent 1393f84 commit b85d7dd
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ecleankernel/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,14 @@ def decompress_raw(self) -> bytes:
# Technically a redundant import, this is just
# to make your IDE happy :)
import zstandard
return zstandard.ZstdDecompressor().decompress(f.read())
reader = zstandard.ZstdDecompressor().stream_reader(f)
decomp = b''
while True:
chunk = reader.read(1024*1024)
if not chunk:
break
decomp += chunk
return decomp
else:
return getattr(mod, 'decompress')(f.read())
return f.read()
Expand Down

0 comments on commit b85d7dd

Please sign in to comment.