diff options
| author | bluebear94 <[email protected]> | 2016-07-23 21:46:34 -0400 |
|---|---|---|
| committer | bluebear94 <[email protected]> | 2016-07-23 21:46:34 -0400 |
| commit | d447f2f4b18e124813ca25d487c8ba433b5da0b8 (patch) | |
| tree | c7e12ce5254c289aa482ee2e9ea1b954ad9f497c | |
| parent | Add functionality for blacklisting compression (diff) | |
| download | kiwad-repacker-d447f2f4b18e124813ca25d487c8ba433b5da0b8.tar.xz kiwad-repacker-d447f2f4b18e124813ca25d487c8ba433b5da0b8.zip | |
Don't bother with compression for bladklisted files
| -rw-r--r-- | repack.py | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -62,14 +62,17 @@ for f in files: if f.is_file():
with f.open(mode="rb") as h:
contents = h.read(-1)
- compressedContents = zlib.compress(contents)
+ isCompressed = not f in blacklist
+ zSize = 0xFFFFFFFF
uSize = len(contents)
- zSize = len(compressedContents)
+ if isCompressed:
+ contents = zlib.compress(contents)
+ zSize = len(contents)
+ isCompressed = zSize < uSize
name = str(f.relative_to(root))
- isCompressed = zSize < uSize and not f in blacklist
crc = zlib.crc32(contents)
entry = {
- "contents": compressedContents if isCompressed else contents,
+ "contents": contents,
"uSize": uSize,
"zSize": zSize,
"name": name,
|