From b183be95a28bd8a6447ec4ffa99d030186e37afc Mon Sep 17 00:00:00 2001 From: sprmn24 Date: Fri, 22 May 2026 16:08:49 +0300 Subject: [PATCH] fix(gateway-windows): atomic write for .cmd and startup launcher scripts --- hermes_cli/gateway_windows.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hermes_cli/gateway_windows.py b/hermes_cli/gateway_windows.py index 77ea60d9b39..e019bb3e638 100644 --- a/hermes_cli/gateway_windows.py +++ b/hermes_cli/gateway_windows.py @@ -365,7 +365,9 @@ def _write_task_script() -> Path: content = _build_gateway_cmd_script(python_path, working_dir, hermes_home, profile_arg) script_path = get_task_script_path() - script_path.write_text(content, encoding="utf-8", newline="") + tmp = script_path.with_suffix(".tmp") + tmp.write_text(content, encoding="utf-8", newline="") + tmp.replace(script_path) return script_path @@ -436,7 +438,9 @@ def _install_startup_entry(script_path: Path) -> Path: """Write the Startup-folder fallback launcher. Returns its path.""" entry = get_startup_entry_path() entry.parent.mkdir(parents=True, exist_ok=True) - entry.write_text(_build_startup_launcher(script_path), encoding="utf-8", newline="") + tmp = entry.with_suffix(".tmp") + tmp.write_text(_build_startup_launcher(script_path), encoding="utf-8", newline="") + tmp.replace(entry) return entry