File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -438,8 +438,16 @@ class ZLIB_legacy(CompressorBase):
438438
439439 def decompress (self , meta , data ):
440440 # note: for compatibility no super call, do not strip ID bytes
441+ assert self .legacy_mode # only borg 1.x repos have the legacy ZLIB format
442+ assert meta is None
443+ meta = {}
444+ meta[" ctype" ] = ZLIB.ID # change to non-legacy ZLIB id
445+ meta[" clevel" ] = 255 # we do not know the compression level
446+ meta[" csize" ] = len (data)
441447 try :
442- return meta, zlib.decompress(data)
448+ data = zlib.decompress(data)
449+ self .check_fix_size(meta, data)
450+ return meta, data
443451 except zlib.error as e:
444452 raise DecompressionError(str (e)) from None
445453
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ def test_lz4_buffer_allocation(monkeypatch):
5050@pytest .mark .parametrize ("invalid_cdata" , [b"\xff \xff totalcrap" , b"\x08 \x00 notreallyzlib" ])
5151def test_autodetect_invalid (invalid_cdata ):
5252 with pytest .raises (ValueError ):
53- Compressor (** params , legacy_mode = True ).decompress ({} , invalid_cdata )
53+ Compressor (** params , legacy_mode = True ).decompress (None , invalid_cdata )
5454
5555
5656def test_zlib_legacy_compat ():
@@ -61,7 +61,7 @@ def test_zlib_legacy_compat():
6161 meta1 , cdata1 = c .compress ({}, DATA )
6262 cdata2 = zlib .compress (DATA , level )
6363 assert cdata1 == cdata2
64- meta2 , data2 = c .decompress ({} , cdata2 )
64+ meta2 , data2 = c .decompress (None , cdata2 )
6565 assert DATA == data2
6666
6767
You can’t perform that action at this time.
0 commit comments