Browse Source

change global compression default to lz4 as well

To be consistent with --compression defaults.
Marian Beermann 8 years ago
parent
commit
929f2760dd
2 changed files with 6 additions and 3 deletions
  1. 3 1
      src/borg/key.py
  2. 3 2
      src/borg/testsuite/key.py

+ 3 - 1
src/borg/key.py

@@ -142,7 +142,9 @@ class KeyBase:
         self.TYPE_STR = bytes([self.TYPE])
         self.repository = repository
         self.target = None  # key location file path / repo obj
-        self.compressor = Compressor('none')  # for decompression
+        # Some commands write new chunks (e.g. rename) but don't take a --compression argument. This duplicates
+        # the default used by those commands who do take a --compression argument.
+        self.compressor = Compressor('lz4')
         self.decompress = self.compressor.decompress
         self.tam_required = True
 

+ 3 - 2
src/borg/testsuite/key.py

@@ -246,8 +246,9 @@ class TestKey:
         key = AuthenticatedKey.create(self.MockRepository(), self.MockArgs())
         plaintext = Chunk(b'123456789')
         authenticated = key.encrypt(plaintext)
-        # 0x06 is the key TYPE, 0x0000 identifies CNONE compression
-        assert authenticated == b'\x06\x00\x00' + plaintext.data
+        # 0x06 is the key TYPE, 0x0100 identifies LZ4 compression, 0x90 is part of LZ4 and means that an uncompressed
+        # block of length nine follows (the plaintext).
+        assert authenticated == b'\x06\x01\x00\x90' + plaintext.data
 
 
 class TestPassphrase: