1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-26 09:47:58 +00:00

catch unpacker exceptions, resync, fixes #1351

This commit is contained in:
Thomas Waldmann 2016-07-28 22:10:29 +02:00
parent 10ecb1792d
commit edea587f35

View file

@ -754,6 +754,9 @@ def valid_msgpacked_dict(d, keys_serialized):
class RobustUnpacker:
"""A restartable/robust version of the streaming msgpack unpacker
"""
class UnpackerCrashed(Exception):
"""raise if unpacker crashed"""
def __init__(self, validator, item_keys):
super().__init__()
self.item_keys = [msgpack.packb(name) for name in item_keys]
@ -798,7 +801,10 @@ def __next__(self):
pass
data = data[1:]
else:
return next(self._unpacker)
try:
return next(self._unpacker)
except (TypeError, ValueError) as err:
raise self.UnpackerCrashed(str(err))
class ArchiveChecker:
@ -1017,6 +1023,9 @@ def valid_item(obj):
yield item
else:
report('Did not get expected metadata dict when unpacking item metadata', chunk_id, i)
except RobustUnpacker.UnpackerCrashed as err:
report('Unpacker crashed while unpacking item metadata, trying to resync...', chunk_id, i)
unpacker.resync()
except Exception:
report('Exception while unpacking item metadata', chunk_id, i)
raise