From 169b349277076c43c7d063224636a0fd166faa01 Mon Sep 17 00:00:00 2001 From: Thomas Peetz Date: Fri, 18 Jul 2025 23:37:00 +0200 Subject: [PATCH] add handling of error condition before renaming file --- kontor-scripts/download.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kontor-scripts/download.py b/kontor-scripts/download.py index d23c328..d8a9ecf 100644 --- a/kontor-scripts/download.py +++ b/kontor-scripts/download.py @@ -87,7 +87,11 @@ def update_status(item_id: UUID, file_info: dict): def rename_file(file_info: dict): 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}") log.info(f"rename {file} to {new_file_path}") file.rename(Path(new_file_path))