extract: fix incorrect progress output for hard links

this produces correct output if any (non proper) subset of hardlinks are
extracted.
This commit is contained in:
Marian Beermann 2016-08-25 01:12:30 +02:00
parent b845a074cb
commit b5d7f1df26
2 changed files with 7 additions and 4 deletions

View File

@ -459,7 +459,7 @@ class Archiver:
if progress: if progress:
progress_logger = logging.getLogger(ProgressIndicatorPercent.LOGGER) progress_logger = logging.getLogger(ProgressIndicatorPercent.LOGGER)
progress_logger.info('Calculating size') 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) pi = ProgressIndicatorPercent(total=extracted_size, msg='Extracting files %5.1f%%', step=0.1)
else: else:
pi = None pi = None

View File

@ -157,10 +157,13 @@ class Item(PropDict):
part = PropDict._make_property('part', int) part = PropDict._make_property('part', int)
def file_size(self): def file_size(self, hardlink_masters=None):
if 'chunks' not in self: 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 0
return sum(chunk.size for chunk in self.chunks) return sum(chunk.size for chunk in chunks)
class EncryptedKey(PropDict): class EncryptedKey(PropDict):