From c7aba15ee24b12cb14f0b3a84f8e5dc9f2ef8d95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Sat, 31 Dec 2022 12:16:50 +0100 Subject: [PATCH] fix: Avoid exception if the redirects key in cache is empty --- lookyloo/capturecache.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lookyloo/capturecache.py b/lookyloo/capturecache.py index 292cc914..5a013ea0 100644 --- a/lookyloo/capturecache.py +++ b/lookyloo/capturecache.py @@ -49,7 +49,11 @@ class CaptureCache(): # If the microsecond is missing (0), it fails self.timestamp = datetime.strptime(cache_entry['timestamp'], '%Y-%m-%dT%H:%M:%S%z') self.url: str = cache_entry['url'] - self.redirects: List[str] = json.loads(cache_entry['redirects']) + if cache_entry.get('redirects'): + self.redirects: List[str] = json.loads(cache_entry['redirects']) + else: + self.logger.info(f'No redirects in cache for {self.uuid}') + self.redirects = [] if not self.capture_dir.exists(): raise MissingCaptureDirectory(f'The capture {self.uuid} does not exists in {self.capture_dir}.') elif not cache_entry.get('error'):