From 50e59bdf3189713cdac0c2c4077bdedde321c51e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Sun, 25 Sep 2022 22:52:42 +0200 Subject: [PATCH] fix: Not having a HAR file is valid now. --- lookyloo/capturecache.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lookyloo/capturecache.py b/lookyloo/capturecache.py index 93d68db..cd0757a 100644 --- a/lookyloo/capturecache.py +++ b/lookyloo/capturecache.py @@ -237,8 +237,12 @@ class CapturesIndex(Mapping): try: tree = load_pickle_tree(capture_dir, capture_dir.stat().st_mtime) except TreeNeedsRebuild: - tree = self._create_pickle(capture_dir) - self.indexing.new_internal_uuids(tree) + try: + tree = self._create_pickle(capture_dir) + self.indexing.new_internal_uuids(tree) + except NoValidHarFile: + # We may not have a HAR file, the reason will be in the error file. + pass cache: Dict[str, Union[str, int]] = {'uuid': uuid, 'capture_dir': capture_dir_str} if (capture_dir / 'error.txt').exists(): @@ -265,7 +269,8 @@ class CapturesIndex(Mapping): except Har2TreeError as e: cache['error'] = str(e) else: - cache['error'] = f'No har files in {capture_dir.name}' + if 'error' not in cache: + cache['error'] = f'No har files in {capture_dir.name}' if (cache.get('error') and isinstance(cache['error'], str)