From 7ea1caf19d051a3ee2784a0ef1435fc27cc633b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Thu, 15 Aug 2024 15:45:59 +0200 Subject: [PATCH] fix: [compare] try to rebuild a broken tree when it seems possible Fix https://github.com/Lookyloo/monitoring/issues/27 --- lookyloo/comparator.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lookyloo/comparator.py b/lookyloo/comparator.py index 173dc30a..281b051b 100644 --- a/lookyloo/comparator.py +++ b/lookyloo/comparator.py @@ -85,6 +85,17 @@ class Comparator(): raise MissingUUID(f'{capture_uuid} does not exists.') 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] try: if capture.error: