fix: avoid exception if the tree cannot be build

pull/562/head
Raphaël Vinot 2022-12-19 17:42:14 +01:00
parent 4461b4e3d5
commit ca7ec64ffe
1 changed files with 2 additions and 1 deletions

View File

@ -286,6 +286,7 @@ class CapturesIndex(Mapping):
self.indexing.new_internal_uuids(tree)
except NoValidHarFile:
self.logger.warning(f'Unable to rebuild the tree for {capture_dir}, the HAR files are broken.')
tree = None
cache: Dict[str, Union[str, int]] = {'uuid': uuid, 'capture_dir': capture_dir_str}
if (capture_dir / 'error.txt').exists():
@ -309,7 +310,7 @@ class CapturesIndex(Mapping):
cache['title'] = har.initial_title
cache['timestamp'] = har.initial_start_time
cache['url'] = har.root_url
cache['redirects'] = json.dumps(tree.redirects)
cache['redirects'] = json.dumps(tree.redirects) if tree else ''
cache['incomplete_redirects'] = 0
cache['user_agent'] = har.root_user_agent if har.root_user_agent else 'No User Agent.'
if har.root_referrer: