Files
cinny-desktop/src-tauri/nsis/hooks.nsh
T

36 lines
1.2 KiB
NSIS
Raw Normal View History

; Lotus Chat NSIS installer hooks (tauri.conf.json → bundle.windows.nsis.installerHooks).
; cinny-desktop #1 — auto-update hit "Error opening file for writing: cinny.exe".
; The updater launches this installer with /UPDATE and then exits the running
; app, but a WebView2 app takes a moment to die; the template only sleeps 500 ms
; after its own kill before copying files, so the copy raced the old process and
; Ignore left the old exe in place. On an update, wait until the exe can really
; be opened for writing (up to 15 s), then let the template carry on as usual.
!macro NSIS_HOOK_PREINSTALL
Push $R7
Push $R8
Push $R9
ClearErrors
${GetOptions} $CMDLINE "/UPDATE" $R7
IfErrors lotus_exe_ready
IfFileExists "$INSTDIR\${MAINBINARYNAME}.exe" 0 lotus_exe_ready
StrCpy $R9 0
lotus_exe_probe:
ClearErrors
FileOpen $R8 "$INSTDIR\${MAINBINARYNAME}.exe" a
IfErrors lotus_exe_locked
FileClose $R8
Goto lotus_exe_ready
lotus_exe_locked:
IntOp $R9 $R9 + 1
; 60 × 250 ms = 15 s; past that fall through to the template's own
; running-app handling rather than hang the update.
IntCmp $R9 60 lotus_exe_ready 0 lotus_exe_ready
Sleep 250
Goto lotus_exe_probe
lotus_exe_ready:
Pop $R9
Pop $R8
Pop $R7
!macroend