From b4ea9a6af4b07abef09357a78b4ecf52f95b96e6 Mon Sep 17 00:00:00 2001 From: javis-bot Date: Sat, 14 Nov 2026 11:34:02 +0900 Subject: [PATCH] fix(app): installer drops its lock before starting the app and refuses a second setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - The lock is closed in a last hidden section once every change is done, so /S /RUN and the finish page's "Jarvis 실행" start the app instead of its "installing" message. - An installer or uninstaller that finds the lock taken (or cannot make it) stops at once, silently with exit code 5, so two never run together. Co-Authored-By: Claude Opus 5.5 --- app/shell/installer.nsi | 47 +++++++++++++++++++++++++++++++++-------- app/src/admin.spec.md | 12 ++++++++--- 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/app/shell/installer.nsi b/app/shell/installer.nsi index c51a2f6..4395068 100644 --- a/app/shell/installer.nsi +++ b/app/shell/installer.nsi @@ -99,9 +99,32 @@ FunctionEnd !macroend ; The installer's lock: Jarvis does not start while it is held (app/src/setup_lock.rs); taken -; before waiting for a running Jarvis, held until the installer ends. +; before waiting for a running Jarvis, closed once every change is done (before the app is started +; again). Another installer or uninstaller holding it (or a lock that cannot be made) means this +; one stops at once: silently with exit code 5. !macro TakeLock - System::Call 'kernel32::CreateMutexW(p 0, i 1, w "Global\JarvisBotSetup") p .r9' + System::Call 'kernel32::CreateMutexW(p 0, i 1, w "Global\JarvisBotSetup") p .r9 ?e' + Pop $8 + ${If} $9 == 0 + ${OrIf} $8 == 183 ; ERROR_ALREADY_EXISTS + ${If} $9 != 0 + System::Call 'kernel32::CloseHandle(p r9)' + ${EndIf} + ${IfNot} ${Silent} + MessageBox MB_ICONSTOP "다른 Jarvis 설치나 제거가 진행 중입니다. 끝난 뒤 다시 실행해 주세요." + ${EndIf} + SetErrorLevel 5 + Abort + ${EndIf} +!macroend + +; Closing the only handle removes the lock (the sections run on another thread than .onInit, so +; ReleaseMutex would not be allowed there; the handle count is what counts). +!macro DropLock + ${If} $9 != 0 + System::Call 'kernel32::CloseHandle(p r9)' + StrCpy $9 0 + ${EndIf} !macroend Function .onInit @@ -196,13 +219,6 @@ Section "Jarvis (필수)" SecMain WriteRegDWORD HKLM "${UNINST_KEY}" "NoRepair" 1 ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2 WriteRegDWORD HKLM "${UNINST_KEY}" "EstimatedSize" $0 - ; Silent updates (/S /RUN) start the app again when done. - ${GetParameters} $0 - ClearErrors - ${GetOptions} $0 "/RUN" $1 - ${IfNot} ${Errors} - Call RunAsUser - ${EndIf} SectionEnd Section "시작 메뉴 바로 가기" SecStart @@ -228,6 +244,18 @@ Section /o "가상 모니터 드라이버" SecDriver ${EndIf} SectionEnd +; Last: every change is done, so the lock goes before the app starts again (silent updates with +; /RUN here, the finish page's "Jarvis 실행" after this). +Section "-Done" + !insertmacro DropLock + ${GetParameters} $0 + ClearErrors + ${GetOptions} $0 "/RUN" $1 + ${IfNot} ${Errors} + Call RunAsUser + ${EndIf} +SectionEnd + LangString DESC_Main ${LANG_KOREAN} "관리 앱과 음성 워커·두뇌 소스입니다. 모델과 런타임은 첫 실행 때 고른 데이터 폴더에 받습니다." LangString DESC_Driver ${LANG_KOREAN} "봇용 크롬창을 실제 모니터에 보이지 않는 가상 모니터에 두어 디스코드 화면 공유에서 고를 수 있게 합니다. Windows가 장치 소프트웨어 설치를 한 번 묻습니다." !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN @@ -268,4 +296,5 @@ Section "Uninstall" DeleteRegKey HKLM "${UNINST_KEY}" DeleteRegKey HKLM "Software\JarvisBot" DetailPrint "데이터 폴더(모델, 대화 기록, 설정)는 지우지 않았습니다." + !insertmacro DropLock SectionEnd diff --git a/app/src/admin.spec.md b/app/src/admin.spec.md index caacea1..a229985 100644 --- a/app/src/admin.spec.md +++ b/app/src/admin.spec.md @@ -582,8 +582,11 @@ come with the first-run wizard into the data folder, which the installer never t asks to retry or cancel; silently it stops with exit code 3, nothing installed and nothing started. - While it installs, updates or removes, the installer holds the named mutex - `Global\JarvisBotSetup` (`setup_lock.rs`); `jarvis.exe` started meanwhile says so in a message - box and exits (code 3) before any window or service. Before copying or removing, the installer + `Global\JarvisBotSetup` (`setup_lock.rs`) from its start until every change is done (a last + hidden section closes it, before `/RUN` and the finish page start the app); `jarvis.exe` started + meanwhile says so in a message box and exits (code 3) before any window or service. Another + installer or uninstaller finding the lock taken (or unable to make it) stops at once with a + message, silently with exit code 5, so two never run together. Before copying or removing, the installer also waits for `jarvis.exe` to close: it asks with a retry, or silently waits up to 60 s (an update closes the app itself), then gives up. - `/S` installs silently with the default components; `/S /RUN` starts the app again afterwards @@ -672,5 +675,8 @@ there is nothing to remove. The installer (by hand on a Windows VM): installing holds other files and uninstalling keeps them; a driver removal that fails stops the uninstall with the files and entry kept, and nothing to remove lets it finish; with no WebView2 and its installer failing nothing is installed or started; with the lock held the app shows its message and exits -after OK, and starts normally once released. On Linux the same window test runs on an X display (one window at the given place and +after OK, and starts normally once released; `/S /RUN` (fresh, and over a running app that closes) +and the finish page's "Jarvis 실행" start the app's window; a silent install while the uninstaller's +window is open, and a silent uninstall while the installer's is, stop with code 5 and change +nothing. On Linux the same window test runs on an X display (one window at the given place and size, the bot's tab in it).