1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-02-23 14:41:43 +00:00

Merge pull request #5076 from elho/auto-compressor-correct-ratio-calculation

correctly calculate compression ratio, taking header size into accoun…
This commit is contained in:
TW 2020-04-04 14:02:44 +02:00 committed by GitHub
commit c19647df38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -311,7 +311,8 @@ class Auto(CompressorBase):
*lz4_data* is the LZ4 result if *compressor* is LZ4 as well, otherwise it is None.
"""
lz4_data = LZ4_COMPRESSOR.compress(data)
ratio = len(lz4_data) / len(data)
# lz4_data includes the compression type header, while data does not yet
ratio = len(lz4_data) / (len(data) + 2)
if ratio < 0.97:
return self.compressor, lz4_data
elif ratio < 1: