44
55from pathlib import Path
66from 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