mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-26 09:47:58 +00:00
archiver checker: better error logging, give chunk_id and sequence numbers
can be used together with borg debug-dump-archive-items.
This commit is contained in:
parent
d2b7dbc0a8
commit
47813f6f6a
1 changed files with 19 additions and 7 deletions
|
@ -788,21 +788,33 @@ def missing_chunk_detector(chunk_id):
|
||||||
_state += 1
|
_state += 1
|
||||||
return _state
|
return _state
|
||||||
|
|
||||||
|
def report(msg, chunk_id, chunk_no):
|
||||||
|
cid = hexlify(chunk_id).decode('ascii')
|
||||||
|
msg += ' [chunk: %06d_%s]' % (chunk_no, cid) # see debug-dump-archive-items
|
||||||
|
self.report_progress(msg, error=True)
|
||||||
|
|
||||||
|
i = 0
|
||||||
for state, items in groupby(archive[b'items'], missing_chunk_detector):
|
for state, items in groupby(archive[b'items'], missing_chunk_detector):
|
||||||
items = list(items)
|
items = list(items)
|
||||||
if state % 2:
|
if state % 2:
|
||||||
self.report_progress('Archive metadata damage detected', error=True)
|
for chunk_id in items:
|
||||||
|
report('item metadata chunk missing', chunk_id, i)
|
||||||
|
i += 1
|
||||||
continue
|
continue
|
||||||
if state > 0:
|
if state > 0:
|
||||||
unpacker.resync()
|
unpacker.resync()
|
||||||
for chunk_id, cdata in zip(items, repository.get_many(items)):
|
for chunk_id, cdata in zip(items, repository.get_many(items)):
|
||||||
unpacker.feed(self.key.decrypt(chunk_id, cdata))
|
unpacker.feed(self.key.decrypt(chunk_id, cdata))
|
||||||
|
try:
|
||||||
for item in unpacker:
|
for item in unpacker:
|
||||||
if not isinstance(item, dict):
|
if isinstance(item, dict):
|
||||||
self.report_progress('Did not get expected metadata dict - archive corrupted!',
|
|
||||||
error=True)
|
|
||||||
continue
|
|
||||||
yield item
|
yield item
|
||||||
|
else:
|
||||||
|
report('Did not get expected metadata dict when unpacking item metadata', chunk_id, i)
|
||||||
|
except Exception:
|
||||||
|
report('Exception while unpacking item metadata', chunk_id, i)
|
||||||
|
raise
|
||||||
|
i += 1
|
||||||
|
|
||||||
repository = cache_if_remote(self.repository)
|
repository = cache_if_remote(self.repository)
|
||||||
if archive is None:
|
if archive is None:
|
||||||
|
|
Loading…
Reference in a new issue