mirror of https://github.com/CIRCL/lookyloo
new: Only update the cached index when displaying index page
parent
844ebc6253
commit
43b23c23ac
|
@ -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:
|
||||
|
|
|
@ -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'''
|
||||
|
|
|
@ -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 ##################
|
||||
|
|
Loading…
Reference in New Issue