mirror of
https://github.com/borgbackup/borg.git
synced 2026-06-09 00:32:37 -04:00
commit
3c0779afa7
2 changed files with 6 additions and 8 deletions
|
|
@ -90,8 +90,8 @@ cdef class CompressorBase:
|
|||
|
||||
def decompress(self, data):
|
||||
"""
|
||||
Decompress *data* (bytes) and return bytes result. The leading Compressor ID
|
||||
bytes need to be present.
|
||||
Decompress *data* (preferably a memoryview, bytes also acceptable) and return bytes result.
|
||||
The leading Compressor ID bytes need to be present.
|
||||
|
||||
Only handles input generated by _this_ Compressor - for a general purpose
|
||||
decompression method see *Compressor.decompress*.
|
||||
|
|
@ -202,9 +202,9 @@ class LZ4(DecidingCompressor):
|
|||
return NONE_COMPRESSOR, None
|
||||
|
||||
def decompress(self, idata):
|
||||
idata = super().decompress(idata)
|
||||
if not isinstance(idata, bytes):
|
||||
idata = bytes(idata) # code below does not work with memoryview
|
||||
idata = super().decompress(idata)
|
||||
cdef int isize = len(idata)
|
||||
cdef int osize
|
||||
cdef int rsize
|
||||
|
|
@ -304,9 +304,9 @@ class ZSTD(DecidingCompressor):
|
|||
return NONE_COMPRESSOR, None
|
||||
|
||||
def decompress(self, idata):
|
||||
idata = super().decompress(idata)
|
||||
if not isinstance(idata, bytes):
|
||||
idata = bytes(idata) # code below does not work with memoryview
|
||||
idata = super().decompress(idata)
|
||||
cdef int isize = len(idata)
|
||||
cdef unsigned long long osize
|
||||
cdef unsigned long long rsize
|
||||
|
|
@ -489,8 +489,6 @@ class ObfuscateSize(CompressorBase):
|
|||
return super().compress(obfuscated_data) # add ID header
|
||||
|
||||
def decompress(self, data):
|
||||
if not isinstance(data, memoryview):
|
||||
data = memoryview(data)
|
||||
obfuscated_data = super().decompress(data) # remove obfuscator ID header
|
||||
compr_size = self.header_fmt.unpack(obfuscated_data[0:self.header_len])[0]
|
||||
compressed_data = obfuscated_data[self.header_len:self.header_len+compr_size]
|
||||
|
|
|
|||
|
|
@ -355,7 +355,7 @@ class AESKeyBase(KeyBase):
|
|||
raise IntegrityError(f"Chunk {bin_to_hex(id)}: Could not decrypt [{str(e)}]")
|
||||
if not decompress:
|
||||
return payload
|
||||
data = self.decompress(payload)
|
||||
data = self.decompress(memoryview(payload))
|
||||
self.assert_id(id, data)
|
||||
return data
|
||||
|
||||
|
|
@ -745,7 +745,7 @@ class AEADKeyBase(KeyBase):
|
|||
raise IntegrityError(f"Chunk {bin_to_hex(id)}: Could not decrypt [{str(e)}]")
|
||||
if not decompress:
|
||||
return payload
|
||||
data = self.decompress(payload)
|
||||
data = self.decompress(memoryview(payload))
|
||||
self.assert_id(id, data)
|
||||
return data
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue