fix: properly handle missing title in cache

pull/746/head
Raphaël Vinot 2023-07-27 15:21:06 +02:00
parent ebfc2f00a5
commit ea2ded9beb
3 changed files with 4 additions and 11 deletions

View File

@ -54,8 +54,6 @@ class BackgroundIndexer(AbstractManager):
self.logger.debug(f'{uuid_path.parent} is locked, pickle generated by another process.')
continue
got_new_captures = True
max_captures -= 1
with uuid_path.open() as f:
uuid = f.read()
@ -80,6 +78,8 @@ class BackgroundIndexer(AbstractManager):
self.lookyloo.get_crawled_tree(uuid)
self.lookyloo.trigger_modules(uuid, auto_trigger=True)
self.logger.info(f'Pickle for {uuid} build.')
got_new_captures = True
max_captures -= 1
except MissingUUID:
self.logger.warning(f'Unable to find {uuid}. That should not happen.')
except NoValidHarFile as e:

View File

@ -74,20 +74,13 @@ class CaptureCache():
if cache_entry.get('title') is not None:
self.title: str = cache_entry['title']
else:
# This shouldn't happen, but if it does, we need the key to exist.
self.logger.warning(f'Title missing in cache for {self.uuid}.')
self.title = ''
if cache_entry.get('timestamp'):
try:
self.timestamp: datetime = datetime.strptime(cache_entry['timestamp'], '%Y-%m-%dT%H:%M:%S.%f%z')
except ValueError:
# If the microsecond is missing (0), it fails
self.timestamp = datetime.strptime(cache_entry['timestamp'], '%Y-%m-%dT%H:%M:%S%z')
else:
# This shouldn't happen, but if it does, we need the key to exist.
self.logger.warning(f'Timestamp missing in cache for {self.uuid}.')
self.timestamp = datetime.fromtimestamp(0)
self.redirects: List[str] = json.loads(cache_entry['redirects']) if cache_entry.get('redirects') else []

View File

@ -774,7 +774,7 @@ def tree(tree_uuid: str, node_uuid: Optional[str]=None):
return render_template('tree.html', tree_json=ct.to_json(),
info=cache,
tree_uuid=tree_uuid, public_domain=lookyloo.public_domain,
screenshot_thumbnail=b64_thumbnail, page_title=cache.title,
screenshot_thumbnail=b64_thumbnail, page_title=cache.title if hasattr(cache, 'title') else '',
screenshot_size=screenshot_size,
meta=meta, enable_mail_notification=enable_mail_notification,
enable_monitoring=lookyloo.monitoring_enabled,