fix: remove broken pickles if needed

pull/135/head
Raphaël Vinot 2020-12-01 17:00:44 +01:00
parent 4e69aa203f
commit 820c7c5a4d
1 changed files with 4 additions and 1 deletions

View File

@ -304,7 +304,10 @@ def load_pickle_tree(capture_dir: Path) -> Optional[CrawledTree]:
pickle_file = capture_dir / 'tree.pickle'
if pickle_file.exists():
with pickle_file.open('rb') as _p:
return pickle.load(_p)
try:
return pickle.load(_p)
except pickle.UnpicklingError:
remove_pickle_tree(capture_dir)
return None