diff --git a/src/borg/compress.pyx b/src/borg/compress.pyx index 9257ced0b..916167252 100644 --- a/src/borg/compress.pyx +++ b/src/borg/compress.pyx @@ -4,9 +4,9 @@ try: except ImportError: lzma = None -from .helpers import Buffer +from .helpers import Buffer, DecompressionError -API_VERSION = '1.1_01' +API_VERSION = '1.1_02' cdef extern from "lz4.h": int LZ4_compress_limitedOutput(const char* source, char* dest, int inputSize, int maxOutputSize) nogil @@ -112,7 +112,7 @@ class LZ4(CompressorBase): break if osize > 2 ** 30: # this is insane, get out of here - raise Exception('lz4 decompress failed') + raise DecompressionError('lz4 decompress failed') # likely the buffer was too small, get a bigger one: osize = int(1.5 * osize) return dest[:rsize] @@ -138,7 +138,10 @@ class LZMA(CompressorBase): def decompress(self, data): data = super().decompress(data) - return lzma.decompress(data) + try: + return lzma.decompress(data) + except lzma.LZMAError as e: + raise DecompressionError(str(e)) from None class ZLIB(CompressorBase): @@ -167,7 +170,10 @@ class ZLIB(CompressorBase): def decompress(self, data): # note: for compatibility no super call, do not strip ID bytes - return zlib.decompress(data) + try: + return zlib.decompress(data) + except zlib.error as e: + raise DecompressionError(str(e)) from None COMPRESSOR_TABLE = { diff --git a/src/borg/helpers.py b/src/borg/helpers.py index 3c38d77d6..37adad23a 100644 --- a/src/borg/helpers.py +++ b/src/borg/helpers.py @@ -81,6 +81,10 @@ class IntegrityError(ErrorWithTraceback): """Data integrity error: {}""" +class DecompressionError(IntegrityError): + """Decompression error: {}""" + + class ExtensionModuleError(Error): """The Borg binary extension modules do not seem to be properly installed""" @@ -99,7 +103,7 @@ def check_extension_modules(): raise ExtensionModuleError if chunker.API_VERSION != '1.1_01': raise ExtensionModuleError - if compress.API_VERSION != '1.1_01': + if compress.API_VERSION != '1.1_02': raise ExtensionModuleError if crypto.API_VERSION != '1.1_01': raise ExtensionModuleError diff --git a/src/borg/testsuite/archiver.py b/src/borg/testsuite/archiver.py index d2142a343..1bff8d5b3 100644 --- a/src/borg/testsuite/archiver.py +++ b/src/borg/testsuite/archiver.py @@ -265,7 +265,7 @@ class ArchiverTestCaseBase(BaseTestCase): return output def create_src_archive(self, name): - self.cmd('create', '--compression=none', self.repository_location + '::' + name, src_dir) + self.cmd('create', '--compression=lz4', self.repository_location + '::' + name, src_dir) def open_archive(self, name): repository = Repository(self.repository_path, exclusive=True)