fix: [compare] try to rebuild a broken tree when it seems possible

Fix https://github.com/Lookyloo/monitoring/issues/27
pull/937/head
Raphaël Vinot 2024-08-15 15:45:59 +02:00
parent 58df880a4a
commit 7ea1caf19d
1 changed files with 11 additions and 0 deletions

View File

@ -85,6 +85,17 @@ class Comparator():
raise MissingUUID(f'{capture_uuid} does not exists.') raise MissingUUID(f'{capture_uuid} does not exists.')
capture = self._captures_index[capture_uuid] capture = self._captures_index[capture_uuid]
# Makes sure the tree is built and valid, force a rebuild otherwise
try:
_ = capture.tree
except TreeNeedsRebuild:
self.logger.warning(f"The tree for {capture_uuid} has to be rebuilt.")
self._captures_index.remove_pickle(capture_uuid)
capture = self._captures_index[capture_uuid]
except LookylooException as e:
return {'error': str(e)}
to_return: dict[str, Any] to_return: dict[str, Any]
try: try:
if capture.error: if capture.error: