浏览代码

key: compress(chunk) return data

Marian Beermann 8 年之前
父节点
当前提交
5a20fc08de
共有 1 个文件被更改,包括 8 次插入9 次删除
  1. 8 9
      src/borg/key.py

+ 8 - 9
src/borg/key.py

@@ -152,8 +152,7 @@ class KeyBase:
 
     def compress(self, chunk):
         meta, data = chunk
-        data = meta.get('compress', self.compressor).compress(data)
-        return Chunk(data, **meta)
+        return meta.get('compress', self.compressor).compress(data)
 
     def encrypt(self, chunk):
         pass
@@ -255,8 +254,8 @@ class PlaintextKey(KeyBase):
         return sha256(data).digest()
 
     def encrypt(self, chunk):
-        chunk = self.compress(chunk)
-        return b''.join([self.TYPE_STR, chunk.data])
+        data = self.compress(chunk)
+        return b''.join([self.TYPE_STR, data])
 
     def decrypt(self, id, data, decompress=True):
         if data[0] != self.TYPE:
@@ -333,10 +332,10 @@ class AESKeyBase(KeyBase):
     MAC = hmac_sha256
 
     def encrypt(self, chunk):
-        chunk = self.compress(chunk)
-        self.nonce_manager.ensure_reservation(num_aes_blocks(len(chunk.data)))
+        data = self.compress(chunk)
+        self.nonce_manager.ensure_reservation(num_aes_blocks(len(data)))
         self.enc_cipher.reset()
-        data = b''.join((self.enc_cipher.iv[8:], self.enc_cipher.encrypt(chunk.data)))
+        data = b''.join((self.enc_cipher.iv[8:], self.enc_cipher.encrypt(data)))
         assert (self.MAC is blake2b_256 and len(self.enc_hmac_key) == 128 or
                 self.MAC is hmac_sha256 and len(self.enc_hmac_key) == 32)
         hmac = self.MAC(self.enc_hmac_key, data)
@@ -745,8 +744,8 @@ class AuthenticatedKey(ID_BLAKE2b_256, RepoKey):
     STORAGE = KeyBlobStorage.REPO
 
     def encrypt(self, chunk):
-        chunk = self.compress(chunk)
-        return b''.join([self.TYPE_STR, chunk.data])
+        data = self.compress(chunk)
+        return b''.join([self.TYPE_STR, data])
 
     def decrypt(self, id, data, decompress=True):
         if data[0] != self.TYPE: