1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-02-22 14:11:27 +00:00

Merge pull request #1275 from ThomasWaldmann/healthy-chunks-list

fixup: only create chunks_healthy if we actually replaced chunks
This commit is contained in:
TW 2016-07-06 23:34:50 +02:00 committed by GitHub
commit d0c16623d5

View file

@ -919,11 +919,12 @@ def verify_file_chunks(item):
"""
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 @@ def verify_file_chunks(item):
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