From a717cab182086b45f0b227eb66a0828d61c66c52 Mon Sep 17 00:00:00 2001 From: Raykov-MS Date: Fri, 17 Jul 2026 11:20:58 +0300 Subject: [PATCH] fix invalid error --- app/pipeline/service.py | 30 +++++++++++++++++++++--------- app/samba_access.py | 9 +++++++++ 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/app/pipeline/service.py b/app/pipeline/service.py index 4463d75..d7b7570 100644 --- a/app/pipeline/service.py +++ b/app/pipeline/service.py @@ -74,15 +74,14 @@ def run_batch( try: ensure_dir_exists(input_dir, samba_conn) except Exception as exc: # noqa: BLE001 - return BatchResult( - status="error", - processed=0, - partial=0, - errors=1, - report_path="", - protocol_path="", - log_path="", - messages=[f"Не удалось создать входную папку: {input_dir}. {exc}"], + return _build_input_dir_error_result( + input_dir=input_dir, + details=str(exc), + ) + if not samba_conn.path_exists(input_dir): + return _build_input_dir_error_result( + input_dir=input_dir, + details="Проверьте права на родительский каталог.", ) is_ok, access_error = check_input_dir_access( input_dir=input_dir, samba_conn=samba_conn @@ -449,3 +448,16 @@ def _format_duration(duration_seconds: float) -> str: if minutes: return f"{minutes} мин {seconds} сек" return f"{seconds} сек" + + +def _build_input_dir_error_result(input_dir: str, details: str) -> BatchResult: + return BatchResult( + status="error", + processed=0, + partial=0, + errors=1, + report_path="", + protocol_path="", + log_path="", + messages=[f"Не удалось создать входную папку: {input_dir}. {details}"], + ) diff --git a/app/samba_access.py b/app/samba_access.py index 7a91def..811f921 100644 --- a/app/samba_access.py +++ b/app/samba_access.py @@ -35,6 +35,15 @@ def check_access_and_list_files( ensure_dir_exists(input_dir, samba_conn=samba_conn) except Exception as exc: # noqa: BLE001 return False, f"Не удалось создать входную папку: {input_dir}. {exc}", [] + if not samba_conn.path_exists(input_dir): + return ( + False, + ( + "Не удалось создать входную папку: " + f"{input_dir}. Проверьте права на родительский каталог." + ), + [], + ) ok, error = check_input_dir_access(Path(input_dir), samba_conn=samba_conn) if not ok: