From 5cc51b3e3e317774238a03dd4ce2ea4e48fbfcb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Fri, 29 Jul 2022 13:08:42 +0200 Subject: [PATCH] chg: Few more improvements in cache. --- lookyloo/capturecache.py | 7 ++++++- lookyloo/lookyloo.py | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lookyloo/capturecache.py b/lookyloo/capturecache.py index 2b464d1..5aac1c5 100644 --- a/lookyloo/capturecache.py +++ b/lookyloo/capturecache.py @@ -18,6 +18,7 @@ from har2tree import CrawledTree, Har2TreeError, HarFile from redis import Redis from .context import Context +from .helpers import get_captures_dir from .indexing import Indexing from .default import LookylooException, try_make_file, get_config from .exceptions import MissingCaptureDirectory, NoValidHarFile, MissingUUID, TreeNeedsRebuild @@ -289,7 +290,11 @@ class CapturesIndex(Mapping): cache['parent'] = f.read().strip() p = self.redis.pipeline() - p.hset('lookup_dirs', uuid, str(capture_dir)) + if capture_dir.is_relative_to(get_captures_dir()): + p.hset('lookup_dirs', uuid, str(capture_dir)) + else: + p.hset('lookup_dirs_archived', uuid, str(capture_dir)) + p.hset(str(capture_dir), mapping=cache) # type: ignore p.execute() return CaptureCache(cache) diff --git a/lookyloo/lookyloo.py b/lookyloo/lookyloo.py index 7defd80..9889d47 100644 --- a/lookyloo/lookyloo.py +++ b/lookyloo/lookyloo.py @@ -978,8 +978,8 @@ class Lookyloo(): continue try: archived.append(CaptureCache(cache)) - except Exception: - continue + except LookylooException as e: + self.logger.warning(f'Unable load cache for {cache.get("uuid")} - {e}.') for cache in self.sorted_capture_cache() + archived: date_submission: datetime = cache.timestamp