mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-27 02:08:54 +00:00
catch unpacker exceptions, resync, fixes #1351
This commit is contained in:
parent
10ecb1792d
commit
edea587f35
1 changed files with 10 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue