fix: remove locks from the archived directories

pull/783/head
Raphaël Vinot 2023-09-18 10:38:05 +02:00
parent 3fb9da8480
commit 1533e33ede
1 changed files with 4 additions and 1 deletions

View File

@ -204,6 +204,7 @@ class Archiver(AbstractManager):
dest_dir.mkdir(parents=True, exist_ok=True) dest_dir.mkdir(parents=True, exist_ok=True)
capture_breakpoint = 100 capture_breakpoint = 100
self.logger.info(f'{len(captures)} captures to archive in {year}-{month}.') self.logger.info(f'{len(captures)} captures to archive in {year}-{month}.')
locks_to_clear: List[Path] = []
for capture_path in captures: for capture_path in captures:
lock_file = capture_path / 'lock' lock_file = capture_path / 'lock'
if try_make_file(lock_file): if try_make_file(lock_file):
@ -240,9 +241,11 @@ class Archiver(AbstractManager):
except OSError as e: except OSError as e:
self.logger.warning(f'Unable to archive capture: {e}') self.logger.warning(f'Unable to archive capture: {e}')
finally: finally:
lock_file.unlink(missing_ok=True) locks_to_clear.append(dest_dir / capture_path.name / 'lock')
# we archived some captures, update relevant index # we archived some captures, update relevant index
self._update_index(dest_dir) self._update_index(dest_dir)
for lock in locks_to_clear:
lock.unlink(missing_ok=True)
if not archiving_done: if not archiving_done:
break break
else: else: