mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-24 10:23:02 -07:00
[Windows] Defer silent updates instead of force-killing the client
This commit is contained in:
parent
e8d9158a53
commit
9290f4daad
1 changed files with 18 additions and 37 deletions
|
|
@ -223,6 +223,12 @@ FunctionEnd
|
||||||
; "The procedure entry point X could not be located in the dynamic link
|
; "The procedure entry point X could not be located in the dynamic link
|
||||||
; library ...Qt6Network.dll" on the next start.
|
; library ...Qt6Network.dll" on the next start.
|
||||||
;
|
;
|
||||||
|
; On a silent update (/R /S) matching processes are asked to close gracefully
|
||||||
|
; (WM_CLOSE) and waited for up to 60 s; if they refuse, the install is aborted
|
||||||
|
; so their data is preserved - a force-kill could destroy an unsaved deck from
|
||||||
|
; Help -> Check for Client Updates. On interactive installs and uninstalls the
|
||||||
|
; user is prompted to close them instead.
|
||||||
|
;
|
||||||
; Processes are matched by image name AND by their executable path living
|
; Processes are matched by image name AND by their executable path living
|
||||||
; under $INSTDIR, so unrelated processes that merely share an image name
|
; under $INSTDIR, so unrelated processes that merely share an image name
|
||||||
; (e.g. the Oracle DB instance "oracle.exe") are never touched.
|
; (e.g. the Oracle DB instance "oracle.exe") are never touched.
|
||||||
|
|
@ -261,12 +267,6 @@ Function CloseMatchingApps
|
||||||
Pop $R3
|
Pop $R3
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
|
|
||||||
Function ForceCloseMatchingApps
|
|
||||||
System::Call 'kernel32::SetEnvironmentVariable(t, t) i ("COCKATRICE_INSTDIR", "$INSTDIR")'
|
|
||||||
nsExec::ExecToLog 'powershell -NoProfile -Command "Get-Process -Name $\'$R2$\' -ErrorAction SilentlyContinue | Where-Object { try { $$p = $$_.Path; if ($$p) { $$p.StartsWith($$env:COCKATRICE_INSTDIR, [StringComparison]::OrdinalIgnoreCase) } else { $$true } } catch { $$true } } | Stop-Process -Force"'
|
|
||||||
Pop $R3
|
|
||||||
FunctionEnd
|
|
||||||
|
|
||||||
Function WaitForAppToClose
|
Function WaitForAppToClose
|
||||||
; usage: set $R1 to the display name (e.g. "cockatrice.exe") and $R2 to the
|
; usage: set $R1 to the display name (e.g. "cockatrice.exe") and $R2 to the
|
||||||
; base image name (e.g. "cockatrice")
|
; base image name (e.g. "cockatrice")
|
||||||
|
|
@ -294,19 +294,12 @@ Function WaitForAppToClose
|
||||||
${If} $R9 < 60000
|
${If} $R9 < 60000
|
||||||
Goto ck_wait_loop
|
Goto ck_wait_loop
|
||||||
${EndIf}
|
${EndIf}
|
||||||
; give up waiting, force close
|
; give up waiting. The application refused to close (e.g. it is showing
|
||||||
DetailPrint "Force closing $R1 ..."
|
; a "really leave this game?" confirmation or holds an unsaved deck).
|
||||||
Call ForceCloseMatchingApps
|
; Do not force-kill it: nothing has been replaced yet, so aborting just
|
||||||
Sleep 500
|
; defers the update and preserves the user's data.
|
||||||
; verify the force close actually worked; a process that cannot be
|
DetailPrint "$R1 is still running after 60 s; aborting the update so that no data is lost."
|
||||||
; terminated (e.g. one owned by another user session) would otherwise
|
Abort
|
||||||
; leave locked files that silently reproduce the very mixed-Qt-DLL bug
|
|
||||||
; this guard exists to prevent.
|
|
||||||
Call IsAppRunning
|
|
||||||
${If} $R0 = 1
|
|
||||||
DetailPrint "WARNING: $R1 is still running; aborting before any files are replaced."
|
|
||||||
Abort
|
|
||||||
${EndIf}
|
|
||||||
${Else}
|
${Else}
|
||||||
ck_wait_prompt:
|
ck_wait_prompt:
|
||||||
MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION|MB_DEFBUTTON1 \
|
MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION|MB_DEFBUTTON1 \
|
||||||
|
|
@ -363,12 +356,6 @@ Function un.CloseMatchingApps
|
||||||
Pop $R3
|
Pop $R3
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
|
|
||||||
Function un.ForceCloseMatchingApps
|
|
||||||
System::Call 'kernel32::SetEnvironmentVariable(t, t) i ("COCKATRICE_INSTDIR", "$INSTDIR")'
|
|
||||||
nsExec::ExecToLog 'powershell -NoProfile -Command "Get-Process -Name $\'$R2$\' -ErrorAction SilentlyContinue | Where-Object { try { $$p = $$_.Path; if ($$p) { $$p.StartsWith($$env:COCKATRICE_INSTDIR, [StringComparison]::OrdinalIgnoreCase) } else { $$true } } catch { $$true } } | Stop-Process -Force"'
|
|
||||||
Pop $R3
|
|
||||||
FunctionEnd
|
|
||||||
|
|
||||||
Function un.WaitForAppToClose
|
Function un.WaitForAppToClose
|
||||||
Call un.IsAppRunning
|
Call un.IsAppRunning
|
||||||
${If} $R0 = 0
|
${If} $R0 = 0
|
||||||
|
|
@ -393,18 +380,12 @@ Function un.WaitForAppToClose
|
||||||
${If} $R9 < 60000
|
${If} $R9 < 60000
|
||||||
Goto un_ck_wait_loop
|
Goto un_ck_wait_loop
|
||||||
${EndIf}
|
${EndIf}
|
||||||
DetailPrint "Force closing $R1 ..."
|
; give up waiting. The application refused to close (e.g. it is showing
|
||||||
Call un.ForceCloseMatchingApps
|
; a "really leave this game?" confirmation or holds an unsaved deck).
|
||||||
Sleep 500
|
; Do not force-kill it: nothing has been replaced yet, so aborting just
|
||||||
; verify the force close actually worked; a process that cannot be
|
; defers the uninstall and preserves the user's data.
|
||||||
; terminated (e.g. one owned by another user session) would otherwise
|
DetailPrint "$R1 is still running after 60 s; aborting so that no data is lost."
|
||||||
; leave locked files that silently reproduce the very mixed-Qt-DLL bug
|
Abort
|
||||||
; this guard exists to prevent.
|
|
||||||
Call un.IsAppRunning
|
|
||||||
${If} $R0 = 1
|
|
||||||
DetailPrint "WARNING: $R1 is still running; aborting before any files are replaced."
|
|
||||||
Abort
|
|
||||||
${EndIf}
|
|
||||||
${Else}
|
${Else}
|
||||||
un_ck_wait_prompt:
|
un_ck_wait_prompt:
|
||||||
MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION|MB_DEFBUTTON1 \
|
MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION|MB_DEFBUTTON1 \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue