fix: Avois error when capture is in a weird state

pull/786/head
Raphaël Vinot 2023-09-18 15:02:33 +02:00
parent 1533e33ede
commit 29fb60e9b7
1 changed files with 12 additions and 7 deletions

View File

@ -102,6 +102,7 @@ class Archiver(AbstractManager):
continue continue
with uuid_file.open() as _f: with uuid_file.open() as _f:
uuid = _f.read().strip() uuid = _f.read().strip()
try:
if not uuid: if not uuid:
self.logger.warning(f'{uuid_file} is empty') self.logger.warning(f'{uuid_file} is empty')
shutil.move(str(capture_dir), str(get_homedir() / 'discarded_captures')) shutil.move(str(capture_dir), str(get_homedir() / 'discarded_captures'))
@ -110,6 +111,10 @@ class Archiver(AbstractManager):
self.logger.warning(f'Duplicate UUID ({uuid}) in {current_index[uuid]} and {uuid_file.parent.name}') self.logger.warning(f'Duplicate UUID ({uuid}) in {current_index[uuid]} and {uuid_file.parent.name}')
shutil.move(str(capture_dir), str(get_homedir() / 'discarded_captures')) shutil.move(str(capture_dir), str(get_homedir() / 'discarded_captures'))
continue continue
except OSError as e:
self.logger.warning(f'Error when discarding capture {capture_dir}: {e}')
continue
current_index[uuid] = uuid_file.parent.name current_index[uuid] = uuid_file.parent.name
if not current_index: if not current_index: