浏览代码

fixup: only create chunks_healthy if we actually replaced chunks

Thomas Waldmann 9 年之前
父节点
当前提交
b0b2ebb6ed
共有 1 个文件被更改,包括 3 次插入2 次删除
  1. 3 2
      borg/archive.py

+ 3 - 2
borg/archive.py

@@ -919,11 +919,12 @@ class ArchiveChecker:
             """
             offset = 0
             chunk_list = []
+            chunks_replaced = False
             for chunk_id, size, csize in item[b'chunks']:
                 if chunk_id not in self.chunks:
                     # If a file chunk is missing, create an all empty replacement chunk
                     logger.error('{}: Missing file chunk detected (Byte {}-{})'.format(item[b'path'].decode('utf-8', 'surrogateescape'), offset, offset + size))
-                    self.error_found = True
+                    self.error_found = chunks_replaced = True
                     data = bytes(size)
                     chunk_id = self.key.id_hash(data)
                     cdata = self.key.encrypt(data)
@@ -933,7 +934,7 @@ class ArchiveChecker:
                     add_reference(chunk_id, size, csize)
                 chunk_list.append((chunk_id, size, csize))
                 offset += size
-            if b'chunks_healthy' not in item:
+            if chunks_replaced and b'chunks_healthy' not in item:
                 # if this is first repair, remember the correct chunk IDs, so we can maybe heal the file later
                 item[b'chunks_healthy'] = item[b'chunks']
             item[b'chunks'] = chunk_list