diff --git a/lookyloo/capturecache.py b/lookyloo/capturecache.py index 044a65e6..c3936594 100644 --- a/lookyloo/capturecache.py +++ b/lookyloo/capturecache.py @@ -156,7 +156,6 @@ class CapturesIndex(Mapping): # type: ignore[type-arg] @property def cached_captures(self) -> set[str]: - self._quick_init() return set(self.__cache.keys()) def __getitem__(self, uuid: str) -> CaptureCache: diff --git a/lookyloo/lookyloo.py b/lookyloo/lookyloo.py index f9a0f73c..b4262c82 100644 --- a/lookyloo/lookyloo.py +++ b/lookyloo/lookyloo.py @@ -190,6 +190,11 @@ class Lookyloo(): loglevel=get_config('generic', 'loglevel')) return self._lacus + def update_cache_index(self) -> None: + '''Update the cache index with the latest captures''' + # NOTE: This call is moderately expensive as it iterates over all the non-archived captures + self._captures_index._quick_init() + def add_context(self, capture_uuid: str, /, urlnode_uuid: str, *, ressource_hash: str, legitimate: bool, malicious: bool, details: dict[str, dict[str, str]]) -> None: '''Adds context information to a capture or a URL node''' diff --git a/website/web/__init__.py b/website/web/__init__.py index 03545e6a..a206fa6c 100644 --- a/website/web/__init__.py +++ b/website/web/__init__.py @@ -1381,6 +1381,7 @@ def index_generic(show_hidden: bool=False, show_error: bool=True, category: str cut_time = (datetime.now() - timedelta(**time_delta_on_index)) cut_time_with_tz = cut_time.replace(tzinfo=timezone.utc) + lookyloo.update_cache_index() for cached in lookyloo.sorted_capture_cache(index_cut_time=cut_time): if cut_time and cached.timestamp < cut_time_with_tz: continue @@ -1548,7 +1549,7 @@ def ressource_by_hash(sha512: str) -> Response: filename, body, mimetype = ressource return send_file(body, as_attachment=True, download_name=filename) - return send_file(BytesIO(f'Unable to find {sha512}'.encode()), as_attachment=True, download_name='Hash unknown.') + return send_file(BytesIO(f'Unable to find {sha512}'.encode()), as_attachment=True, download_name='Unknown_Hash.txt') # ################## Submit existing capture ##################