From 8f283350105729bfa703af954a46f9e5d14053ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Mon, 23 Aug 2021 15:51:06 +0200 Subject: [PATCH] fix: properly match cut time --- bin/archiver.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/archiver.py b/bin/archiver.py index beb6391d..20adfbf5 100755 --- a/bin/archiver.py +++ b/bin/archiver.py @@ -34,14 +34,16 @@ class Archiver(AbstractManager): archived_captures_dir.mkdir(parents=True, exist_ok=True) archive_interval = timedelta(days=get_config('generic', 'archive')) cut_time = (datetime.now() - archive_interval).date() - cut_time.replace(day=1) + cut_time = cut_time.replace(day=1) # Format: # { 2020: { 12: [(directory, uuid)] } } to_archive: Dict[int, Dict[int, List[Tuple[Path, str]]]] = defaultdict(lambda: defaultdict(list)) for capture_path in lookyloo.capture_dir.glob('*'): + if not capture_path.is_dir(): + continue timestamp = datetime.strptime(capture_path.name, '%Y-%m-%dT%H:%M:%S.%f') - if timestamp >= cut_time: + if timestamp.date() >= cut_time: # do not archive. continue with (capture_path / 'uuid').open() as _f: