Skip to content

Commit a5f92fc

Browse files
committed
use 32 bit crc for xz by default
Signed-off-by: Zen <[email protected]>
1 parent b2ef2c0 commit a5f92fc

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "pycpio"
7-
version = "1.1.1"
7+
version = "1.1.2"
88
authors = [
99
{ name="Desultory", email="[email protected]" },
1010
]

src/pycpio/writer/writer.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from pathlib import Path
66
from os import fsync
7+
from lzma import CHECK_CRC32
78

89

910
@loggify
@@ -12,12 +13,13 @@ class CPIOWriter:
1213
Takes a list of CPIOData objects, gets their bytes representation, then appends a trailer before writing them to a file.
1314
Compresses the data if compression is specified.
1415
"""
15-
def __init__(self, cpio_entries: list, output_file: Path, compression=None, structure=None, *args, **kwargs):
16+
def __init__(self, cpio_entries: list, output_file: Path, structure=None, compression=None, xz_crc=CHECK_CRC32, *args, **kwargs):
1617
self.cpio_entries = cpio_entries
1718
self.output_file = Path(output_file)
1819

1920
self.structure = structure if structure is not None else HEADER_NEW
2021
self.compression = compression
22+
self.xz_crc = xz_crc
2123

2224
def __bytes__(self):
2325
""" Creates a bytes representation of the CPIOData objects. """
@@ -32,7 +34,7 @@ def compress(self, data):
3234
if self.compression == 'xz':
3335
import lzma
3436
self.logger.info("Compressing data with xz, original size: %d" % len(data))
35-
data = lzma.compress(data)
37+
data = lzma.compress(data, check=self.xz_crc)
3638
elif self.compression not in [False, 'False', None, '', 'false']:
3739
raise NotImplementedError("Compression type not supported: %s" % self.compression)
3840
return data

0 commit comments

Comments
 (0)