fix: Avoid exception if the redirects key in cache is empty

pull/564/head
Raphaël Vinot 2022-12-31 12:16:50 +01:00
parent 2e015ba978
commit c7aba15ee2
1 changed files with 5 additions and 1 deletions

View File

@ -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'):