浏览代码

extract: fix incorrect progress output for hard links

this produces correct output if any (non proper) subset of hardlinks are
extracted.
Marian Beermann 8 年之前
父节点
当前提交
b5d7f1df26
共有 2 个文件被更改,包括 7 次插入4 次删除
  1. 1 1
      src/borg/archiver.py
  2. 6 3
      src/borg/item.py

+ 1 - 1
src/borg/archiver.py

@@ -459,7 +459,7 @@ class Archiver:
         if progress:
             progress_logger = logging.getLogger(ProgressIndicatorPercent.LOGGER)
             progress_logger.info('Calculating size')
-            extracted_size = sum(item.file_size() for item in archive.iter_items(filter))
+            extracted_size = sum(item.file_size(hardlink_masters) for item in archive.iter_items(filter))
             pi = ProgressIndicatorPercent(total=extracted_size, msg='Extracting files %5.1f%%', step=0.1)
         else:
             pi = None

+ 6 - 3
src/borg/item.py

@@ -157,10 +157,13 @@ class Item(PropDict):
 
     part = PropDict._make_property('part', int)
 
-    def file_size(self):
-        if 'chunks' not in self:
+    def file_size(self, hardlink_masters=None):
+        hardlink_masters = hardlink_masters or {}
+        chunks, _ = hardlink_masters.get(self.get('source'), (None, None))
+        chunks = self.get('chunks', chunks)
+        if chunks is None:
             return 0
-        return sum(chunk.size for chunk in self.chunks)
+        return sum(chunk.size for chunk in chunks)
 
 
 class EncryptedKey(PropDict):