add handling of error condition before renaming file

This commit is contained in:
Thomas Peetz
2025-07-18 23:37:00 +02:00
parent 9c0de2a0be
commit 169b349277
+5 -1
View File
@@ -87,7 +87,11 @@ def update_status(item_id: UUID, file_info: dict):
def rename_file(file_info: dict): def rename_file(file_info: dict):
item_id = file_info['id'] item_id = file_info['id']
file = Path(args.dir, file_info['file_name']) file_name = file_info['file_name']
if file_name is None:
log.info("file_anme is not set, rename is not executed")
return
file = Path(args.dir, file_name)
new_file_path = file.with_name(f"{item_id}{file.suffix}") new_file_path = file.with_name(f"{item_id}{file.suffix}")
log.info(f"rename {file} to {new_file_path}") log.info(f"rename {file} to {new_file_path}")
file.rename(Path(new_file_path)) file.rename(Path(new_file_path))