fix(desktop): release Windows app locks at staged promotion

Salvage #101887 after native Actions 34097643131 reproduced WinError 32 using a ready Electron app with its cwd inside the live release. Reuse the existing install-scoped process cleanup before promotion and wait after forced termination, preserving rollback.

Co-authored-by: fangliquan <fangliquan@qq.com>
This commit is contained in:
Teknium
2026-09-07 00:56:34 -07:00
parent 1f92ab1ddf
commit f17f18cd11
2 changed files with 10 additions and 0 deletions
+8
View File
@@ -207,6 +207,10 @@ def _swap_staged_desktop_app(desktop_dir: Path, staging_dir: Path) -> Optional[P
shutil.rmtree(previous, ignore_errors=True)
moved_aside = live_root.exists()
if moved_aside:
# A Desktop may have reopened during the long packaging step.
stopped = _stop_desktop_processes_locking_build(desktop_dir)
if stopped:
logger.info("stopped desktop processes before staged app promotion: %s", stopped)
os.rename(live_root, previous)
try:
os.rename(staged_root, live_root)
@@ -669,11 +673,15 @@ def _stop_desktop_processes_locking_build(desktop_dir: Path) -> list[int]:
# Wait for the handles (and thus the file locks) to actually release.
with contextlib.suppress(Exception):
_, alive = psutil.wait_procs(victims, timeout=5)
killed = []
for proc in alive:
try:
proc.kill()
killed.append(proc)
except Exception:
continue
if killed:
psutil.wait_procs(killed, timeout=5)
return stopped
+2
View File
@@ -46,6 +46,8 @@ When you run `hermes update`, the following steps occur:
If the maintained updater script is missing (for example after antivirus quarantine), the legacy update forwarder fails instead of reporting a successful hand-off. Repair the installation and review the security software's quarantine report before retrying; do not disable antivirus protection. Before reporting success, the maintained updater checks the CLI import, Windows executable header, ASAR header and packaged main entry, readable renderer HTML with a local module entry, initial module files, and current build stamp. These are minimum artifact checks, not a full dependency audit or an application/backend launch test. Missing Python is reported before waiting for Desktop shutdown; dependency repair is still allowed to run as part of the update. Electron checks maintained handoff prerequisites before stopping backends when that layout is present; genuine legacy-flat updater layouts remain supported, so not every missing updater file is detected before backend shutdown.
On Windows, a Desktop reopened during packaging is stopped again immediately before the staged build is promoted. This cleanup is restricted to executables inside that checkout's Desktop release tree; unrelated installations are not stopped. A remaining lock still makes staged promotion fail rather than bypassing the rename error.
### Updating against a non-default branch: `--branch`
By default `hermes update` tracks `origin/main`. Pass `--branch <name>` to update against a different branch — useful for QA channels, feature branches, or release-candidate testing: