fix(app): installer removes only its own files and stops on failed steps
- installer.sh lists every packaged file for the uninstaller, and folders are removed only when empty, so a chosen folder keeps other files. - A virtual monitor driver removal that fails stops the uninstall with everything kept (silent exit code 4); the elevated half exits 2 when there is no driver of ours to remove, which the uninstaller accepts. - WebView2 is installed before any file is copied; when it is still missing the installer asks to retry, or silently stops with code 3 without installing or starting anything. - The installer holds Global\JarvisBotSetup while it runs; jarvis.exe started meanwhile shows a message and exits before any window. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
41
app/src/setup_lock.rs
Normal file
41
app/src/setup_lock.rs
Normal file
@@ -0,0 +1,41 @@
|
||||
//! The installer's lock (admin.spec.md, "Installer"): while Jarvis is installed, updated or
|
||||
//! removed, the installer holds the named mutex `Global\JarvisBotSetup`, and the app does not
|
||||
//! start meanwhile (it would hold files being replaced, or start services on a driver being
|
||||
//! removed).
|
||||
|
||||
pub const MUTEX: &str = "Global\\JarvisBotSetup";
|
||||
|
||||
/// Whether an installer holds the lock (also when this user may not open it: it exists).
|
||||
#[cfg(windows)]
|
||||
pub fn held() -> bool {
|
||||
use windows_sys::Win32::Foundation::{CloseHandle, GetLastError, ERROR_ACCESS_DENIED};
|
||||
use windows_sys::Win32::System::Threading::{OpenMutexW, SYNCHRONIZATION_SYNCHRONIZE};
|
||||
let name: Vec<u16> = MUTEX.encode_utf16().chain(Some(0)).collect();
|
||||
// SAFETY: opening a named object by a NUL-terminated name; the handle is closed at once.
|
||||
unsafe {
|
||||
let h = OpenMutexW(SYNCHRONIZATION_SYNCHRONIZE, 0, name.as_ptr());
|
||||
if !h.is_null() {
|
||||
CloseHandle(h);
|
||||
return true;
|
||||
}
|
||||
GetLastError() == ERROR_ACCESS_DENIED
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
pub fn held() -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
/// Say so in a message box (the app has no window yet).
|
||||
#[cfg(windows)]
|
||||
pub fn tell() {
|
||||
use windows_sys::Win32::UI::WindowsAndMessaging::{MessageBoxW, MB_ICONINFORMATION, MB_OK};
|
||||
let text: Vec<u16> = "Jarvis를 설치하거나 제거하는 중입니다. 끝난 뒤 다시 실행해 주세요.".encode_utf16().chain(Some(0)).collect();
|
||||
let title: Vec<u16> = "Jarvis".encode_utf16().chain(Some(0)).collect();
|
||||
// SAFETY: NUL-terminated strings; no owner window.
|
||||
unsafe { MessageBoxW(std::ptr::null_mut(), text.as_ptr(), title.as_ptr(), MB_OK | MB_ICONINFORMATION) };
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
pub fn tell() {}
|
||||
Reference in New Issue
Block a user