chg: Cleanup when dir is moved, digit months on 2 values

pull/251/head
Raphaël Vinot 2021-08-23 14:53:19 +02:00
parent b8109c6462
commit 53ceb9c329
2 changed files with 3 additions and 1 deletions

View File

@ -54,7 +54,7 @@ class Archiver(AbstractManager):
archived_uuids = {}
for year, month_captures in to_archive.items():
for month, captures in month_captures.items():
dest_dir = archived_captures_dir / str(year) / str(month)
dest_dir = archived_captures_dir / str(year) / f'{month:02}'
dest_dir.mkdir(parents=True, exist_ok=True)
if (dest_dir / 'index').exists():
with (dest_dir / 'index').open('r') as _f:
@ -74,6 +74,7 @@ class Archiver(AbstractManager):
lookyloo.redis.hdel('lookup_dirs', *archived_uuids.keys())
lookyloo.redis.hset('lookup_dirs_archived', mapping=archived_uuids)
lookyloo.clear_captures_index_cache(archived_uuids.keys())
self.logger.info('Archiving done.')
def main():

View File

@ -624,6 +624,7 @@ class Lookyloo():
capture_dir = self._captures_index[capture_uuid].capture_dir
if capture_dir.exists():
return capture_dir
self.redis.delete(capture_dir)
self._captures_index.pop(capture_uuid)
capture_dir = self.redis.hget('lookup_dirs', capture_uuid)
if capture_dir and not Path(capture_dir).exists():