1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-25 01:06:50 +00:00

borg check: check file size consistency

This commit is contained in:
Thomas Waldmann 2017-02-18 23:09:40 +01:00
parent 50068c596d
commit adc4da280d
2 changed files with 10 additions and 1 deletions

View file

@ -1306,6 +1306,13 @@ def replacement_chunk(size):
logger.info('{}: Completely healed previously damaged file!'.format(item.path))
del item.chunks_healthy
item.chunks = chunk_list
if 'size' in item:
item_size = item.size
item_chunks_size = item.get_size(compressed=False, from_chunks=True)
if item_size != item_chunks_size:
# just warn, but keep the inconsistency, so that borg extract can warn about it.
logger.warning('{}: size inconsistency detected: size {}, chunks size {}'.format(
item.path, item_size, item_chunks_size))
def robust_iterator(archive):
"""Iterates through all archive items

View file

@ -176,7 +176,7 @@ class Item(PropDict):
part = PropDict._make_property('part', int)
def get_size(self, hardlink_masters=None, memorize=False, compressed=False):
def get_size(self, hardlink_masters=None, memorize=False, compressed=False, from_chunks=False):
"""
Determine the (uncompressed or compressed) size of this item.
@ -187,6 +187,8 @@ class Item(PropDict):
"""
attr = 'csize' if compressed else 'size'
try:
if from_chunks:
raise AttributeError
size = getattr(self, attr)
except AttributeError:
# no precomputed (c)size value available, compute it: