chg: yet another attempt to improve checking archived captures

pull/798/head
Raphaël Vinot 2023-10-02 15:47:31 +02:00
parent 1220f5926d
commit f250cba632
1 changed files with 6 additions and 5 deletions

View File

@ -76,14 +76,15 @@ class Archiver(AbstractManager):
curent_index_dirs = set(current_index.values()) curent_index_dirs = set(current_index.values())
existing_captures_names = {existing_capture.name for existing_capture in root_dir.iterdir() with os.scandir(root_dir) as it:
if (existing_capture.name in curent_index_dirs) or existing_capture.is_dir()} new_captures = {existing_capture.name for existing_capture in it
if curent_index_dirs == existing_captures_names: if (existing_capture.name not in curent_index_dirs) and existing_capture.is_dir()}
if not new_captures:
# No new captures, quitting # No new captures, quitting
self.logger.debug(f'No new captures in {root_dir}.') self.logger.debug(f'No new captures in {root_dir}.')
return return
new_captures = sorted(existing_captures_names - set(current_index.values()), reverse=True)
self.logger.info(f'{len(new_captures)} new captures in {root_dir}.') self.logger.info(f'{len(new_captures)} new captures in {root_dir}.')
for capture_dir_name in new_captures: for capture_dir_name in new_captures:
@ -329,7 +330,7 @@ class Archiver(AbstractManager):
def main(): def main():
a = Archiver() a = Archiver()
a.run(sleep_in_sec=3600) a.run(sleep_in_sec=36000)
if __name__ == '__main__': if __name__ == '__main__':