Skip to content

Commit fe41cfd

Browse files
committed
Move the selection between the native and Python implementations of lzo and lz4 to dissect.util
1 parent a28fea9 commit fe41cfd

File tree

2 files changed

+5
-23
lines changed

2 files changed

+5
-23
lines changed

dissect/squashfs/compression.py

+5-19
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ def initialize(id: int, options: Optional[bytes]) -> Compression:
1111
modules = {
1212
c_squashfs.ZLIB_COMPRESSION: (NativeZlib,),
1313
c_squashfs.LZMA_COMPRESSION: (NativeLZMA,),
14-
c_squashfs.LZO_COMPRESSION: (NativeLZO, PythonLZO),
14+
c_squashfs.LZO_COMPRESSION: (AvailableLZO,),
1515
c_squashfs.XZ_COMPRESSION: (NativeXZ,),
16-
c_squashfs.LZ4_COMPRESSION: (NativeLZ4, PythonLZ4),
16+
c_squashfs.LZ4_COMPRESSION: (AvailableLZ4,),
1717
c_squashfs.ZSTD_COMPRESSION: (NativeZSTD,),
1818
}
1919

@@ -60,14 +60,7 @@ def decompress(self, data: bytes, expected: int) -> bytes:
6060
return self._module.decompress(data)
6161

6262

63-
class NativeLZO(Compression):
64-
module = "lzo"
65-
66-
def decompress(self, data: bytes, expected: int) -> bytes:
67-
return self._module.decompress(data, False, expected)
68-
69-
70-
class PythonLZO(Compression):
63+
class AvailableLZO(Compression):
7164
module = "dissect.util.compression.lzo"
7265

7366
def decompress(self, data: bytes, expected: int) -> bytes:
@@ -81,18 +74,11 @@ def decompress(self, data: bytes, expected: int) -> bytes:
8174
return self._module.decompress(data)
8275

8376

84-
class NativeLZ4(Compression):
85-
module = "lz4.block"
86-
87-
def decompress(self, data: bytes, expected: int) -> bytes:
88-
return self._module.decompress(data, expected)
89-
90-
91-
class PythonLZ4(Compression):
77+
class AvailableLZ4(Compression):
9278
module = "dissect.util.compression.lz4"
9379

9480
def decompress(self, data: bytes, expected: int) -> bytes:
95-
return self._module.decompress(data)
81+
return self._module.decompress(data, uncompressed_size=expected)
9682

9783

9884
class NativeZSTD(Compression):

pyproject.toml

-4
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ repository = "https://github.com/fox-it/dissect.squashfs"
3737

3838
[project.optional-dependencies]
3939
full = [
40-
"lz4",
41-
# There are no Windows PyPy wheels available for python-lzo
42-
# So we use a pure python fallback for it.
43-
"python-lzo; platform_system != 'Windows' or platform_python_implementation != 'PyPy'",
4440
"zstandard",
4541
]
4642
dev = [

0 commit comments

Comments
 (0)