From e9dad5de6168606886b6e2c2443235db92dd611b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Fri, 4 Aug 2023 15:03:58 +0200 Subject: [PATCH] chg: Attempt to reduce disk use --- bin/archiver.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/archiver.py b/bin/archiver.py index f8eed940..4dfac402 100755 --- a/bin/archiver.py +++ b/bin/archiver.py @@ -180,9 +180,13 @@ class Archiver(AbstractManager): self.logger.warning('Shutdown requested, breaking.') break with index.open('r') as _f: - archived_uuids: Mapping = {uuid: str(index.parent / dirname) for uuid, dirname in csv.reader(_f) if (index.parent / dirname).exists()} + archived_uuids: Mapping = {uuid: index.parent / dirname for uuid, dirname in csv.reader(_f)} if archived_uuids: - self.redis.hset('lookup_dirs_archived', mapping=archived_uuids) + new_uuids = set(archived_uuids.keys()) - set(self.redis.hkeys('lookup_dirs_archived')) + # NOTE: Only check if the directory exists if the UUID isn't in the cache. + self.redis.hset('lookup_dirs_archived', mapping={uuid: str(dirname) + for uuid, dirname in archived_uuids.items() + if uuid in new_uuids and dirname.exists()}) self.redis.hdel('lookup_dirs', *archived_uuids.keys()) else: index.unlink()