浏览代码

correctly calculate compression ratio, taking header size into account, too

Elmar Hoffmann 5 年之前
父节点
当前提交
54ab8cd917
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      src/borg/compress.pyx

+ 2 - 1
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: