fix: force-rebuild pickle if needed.

pull/265/head
Raphaël Vinot 2021-09-22 22:23:20 +02:00
parent 7afd150570
commit 19c8c54b0b
1 changed files with 6 additions and 2 deletions

View File

@ -27,7 +27,7 @@ from werkzeug.useragents import UserAgent
from .capturecache import CaptureCache, CapturesIndex from .capturecache import CaptureCache, CapturesIndex
from .context import Context from .context import Context
from .exceptions import (LookylooException, MissingCaptureDirectory, from .exceptions import (LookylooException, MissingCaptureDirectory,
MissingUUID) MissingUUID, TreeNeedsRebuild)
from .helpers import (CaptureStatus, get_captures_dir, get_config, from .helpers import (CaptureStatus, get_captures_dir, get_config,
get_email_template, get_homedir, get_resources_hashes, get_email_template, get_homedir, get_resources_hashes,
get_socket_path, get_splash_url, get_taxonomies, uniq_domains) get_socket_path, get_splash_url, get_taxonomies, uniq_domains)
@ -336,7 +336,11 @@ class Lookyloo():
def get_crawled_tree(self, capture_uuid: str, /) -> CrawledTree: def get_crawled_tree(self, capture_uuid: str, /) -> CrawledTree:
'''Get the generated tree in ETE Toolkit format. '''Get the generated tree in ETE Toolkit format.
Loads the pickle if it exists, creates it otherwise.''' Loads the pickle if it exists, creates it otherwise.'''
return self._captures_index[capture_uuid].tree try:
return self._captures_index[capture_uuid].tree
except TreeNeedsRebuild:
self._captures_index.reload_cache(capture_uuid)
return self._captures_index[capture_uuid].tree
def enqueue_capture(self, query: MutableMapping[str, Any], source: str, user: str, authenticated: bool) -> str: def enqueue_capture(self, query: MutableMapping[str, Any], source: str, user: str, authenticated: bool) -> str:
'''Enqueue a query in the capture queue (used by the UI and the API for asynchronous processing)''' '''Enqueue a query in the capture queue (used by the UI and the API for asynchronous processing)'''