fix(gateway-windows): atomic write for .cmd and startup launcher scripts#30435
Closed
sprmn24 wants to merge 1 commit into
Closed
fix(gateway-windows): atomic write for .cmd and startup launcher scripts#30435sprmn24 wants to merge 1 commit into
sprmn24 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
_write_task_script()and_install_startup_entry()both usePath.write_text()to write the scheduled-task.cmdscript and the Startup-folder launcher directly. If the process is killed or crashes mid-write (OOM, power loss, SIGKILL during install), the target file is left partially written. On the next Windows login the Scheduled Task fires against a truncated script and the gateway silently never starts — with no diagnostic in Task Scheduler.Type of Change
Changes Made
_write_task_script(): write toscript_path.with_suffix('.tmp')first, thentmp.replace(script_path)_install_startup_entry(): same temp-file + atomic rename patternThis matches the pattern already used throughout the codebase (
cron/jobs.py,agent/google_oauth.py,agent/anthropic_adapter.py, etc.).How to Test
hermes_cli/gateway_windows.py—_write_task_script()and_install_startup_entry()with_suffix('.tmp')+tmp.replace()instead of directwrite_text()python -m pytest tests/ -q— no regressions expectedChecklist
Code
Documentation & Housekeeping