From 54ab8cd917d27c7cc6a06e17e08fba3d8e43f0f6 Mon Sep 17 00:00:00 2001 From: Elmar Hoffmann Date: Fri, 3 Apr 2020 17:21:11 +0200 Subject: [PATCH] correctly calculate compression ratio, taking header size into account, too --- src/borg/compress.pyx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/borg/compress.pyx b/src/borg/compress.pyx index 687397d5d..c0b0aafdf 100644 --- a/src/borg/compress.pyx +++ b/src/borg/compress.pyx @@ -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: