Installer: close everything running from the app's folder before copying
Updating 1.4.35 -> 1.4.36 on the TV stopped at "Bible App cannot be closed. Please close it manually and click Retry" with the app plainly closed. That message also comes from the installer's copy step (and from removing the old version) when any file in the install folder is in use — not only when Bible App.exe is running. The app runs programs from its own folder: the local AI server (llama-server.exe), speech (whisper-cli.exe), the upscaler. electron-builder's stock check closes only Bible App.exe, and when it has to force-close the app, the app's own shutdown (which stops the AI server) never runs. The orphaned llama-server.exe then holds its files open forever, so Retry can never succeed. - build/installer.nsh: customCheckAppRunning replaces the stock check. It asks the app to close, force-closes any Bible App.exe left, force-closes the helpers by name, then, as a backstop, every process whose executable is inside the install folder (via WMI, which works from the 32-bit installer on 64-bit Windows; the folder is passed in an environment variable and a bare drive is refused). It runs before the old version is removed and before any file is copied. - main.cjs: the in-app updater stops the AI server before launching the installer. The fix is in the INSTALLER, so the TV still on 1.4.35 gets it with this release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,3 +4,42 @@
|
||||
IfFileExists "$INSTDIR\resources\app.asar.unpacked\vendor\redist\vc_redist.x64.exe" 0 +2
|
||||
ExecWait '"$INSTDIR\resources\app.asar.unpacked\vendor\redist\vc_redist.x64.exe" /install /quiet /norestart' $0
|
||||
!macroend
|
||||
|
||||
; ---------------------------------------------------------------------------------------------------
|
||||
; Replaces electron-builder's "is the app running?" check (customCheckAppRunning). Runs at the start of
|
||||
; installing, BEFORE the old version is removed and before any file is copied.
|
||||
;
|
||||
; The stock check only looks for "Bible App.exe". But the app also starts programs from its own folder
|
||||
; - the local AI server (llama-server.exe), speech (whisper), the upscaler - and if the app is closed
|
||||
; hard, those are left running. They hold their files open, so copying the new version fails and the
|
||||
; installer says "Bible App cannot be closed. Please close it manually and click Retry" even though
|
||||
; the app is plainly closed, and Retry can never succeed. So:
|
||||
; 1. ask the app to close (it then stops the AI server itself), and give it a moment;
|
||||
; 2. force-close anything named Bible App.exe that is still there;
|
||||
; 3. force-close the app's own helper programs by name (plain taskkill, nothing to go wrong);
|
||||
; 4. as a backstop, force-close EVERY program running from this install folder, whatever its name.
|
||||
; Step 4 matches by folder, via WMI (works from this 32-bit installer on 64-bit Windows, where a
|
||||
; 32-bit process cannot read a 64-bit process's path). The folder travels in an environment variable
|
||||
; so a quote or space in it can never break the command, and it refuses to act on a bare drive.
|
||||
; No question is asked first: installing this version replaces the app, which is what was asked for.
|
||||
; ---------------------------------------------------------------------------------------------------
|
||||
!macro customCheckAppRunning
|
||||
DetailPrint `Closing "${PRODUCT_NAME}"...`
|
||||
nsExec::Exec `"$SYSDIR\cmd.exe" /c taskkill /im "${APP_EXECUTABLE_FILENAME}" /fi "USERNAME eq %USERNAME%"`
|
||||
Pop $0
|
||||
Sleep 2500
|
||||
nsExec::Exec `"$SYSDIR\cmd.exe" /c taskkill /f /t /im "${APP_EXECUTABLE_FILENAME}" /fi "USERNAME eq %USERNAME%"`
|
||||
Pop $0
|
||||
nsExec::Exec `"$SYSDIR\cmd.exe" /c taskkill /f /t /im llama-server.exe /im whisper-cli.exe /im realesrgan-ncnn-vulkan.exe /fi "USERNAME eq %USERNAME%"`
|
||||
Pop $0
|
||||
System::Call 'Kernel32::SetEnvironmentVariable(t "BIBLEAPP_INSTDIR", t "$INSTDIR")'
|
||||
StrCpy $1 "$SYSDIR\WindowsPowerShell\v1.0\powershell.exe"
|
||||
${If} ${FileExists} "$WINDIR\Sysnative\WindowsPowerShell\v1.0\powershell.exe"
|
||||
StrCpy $1 "$WINDIR\Sysnative\WindowsPowerShell\v1.0\powershell.exe"
|
||||
${EndIf}
|
||||
StrCpy $2 `"$1" -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command "$$r = $$env:BIBLEAPP_INSTDIR.TrimEnd('\'); if ($$r.Split('\').Count -lt 2) { exit }; $$d = $$r + '\'; Get-CimInstance Win32_Process | Where-Object { $$_.ExecutablePath -and $$_.ExecutablePath.StartsWith($$d, [StringComparison]::OrdinalIgnoreCase) } | ForEach-Object { Stop-Process -Id $$_.ProcessId -Force -ErrorAction SilentlyContinue }"`
|
||||
DetailPrint `Closing anything else still running from "${PRODUCT_NAME}"'s folder...`
|
||||
nsExec::Exec $2
|
||||
Pop $0
|
||||
Sleep 1000
|
||||
!macroend
|
||||
|
||||
Reference in New Issue
Block a user