add handling of error condition before renaming file
This commit is contained in:
@@ -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))
|
||||||
|
|||||||
Reference in New Issue
Block a user