From 4b6d0780c91e19df861bb288d0a1227966302c56 Mon Sep 17 00:00:00 2001 From: Youwes09 Date: Fri, 27 Mar 2026 20:59:22 -0500 Subject: [PATCH] Fix: Installation Server Kill [V2] --- PKGBUILD | 2 +- package.json | 2 +- src-tauri/src/lib.rs | 29 ++++++++++++++++++++++--- src/components/settings/Settings.svelte | 5 ++--- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index be51486..a6f150d 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,5 +1,5 @@ pkgname=moku -pkgver=0.4.0 +pkgver=0.5.0 pkgrel=1 pkgdesc="Native Linux manga reader frontend for Suwayomi-Server" arch=('x86_64') diff --git a/package.json b/package.json index 83c1254..7296331 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "moku", - "version": "0.1.0", + "version": "0.5.0", "type": "module", "scripts": { "dev": "vite", diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 60f1f43..cb9f0b4 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -121,9 +121,31 @@ fn kill_tachidesk(app: &tauri::AppHandle) { } #[cfg(target_os = "windows")] - let _ = std::process::Command::new("taskkill") - .args(["/F", "/FI", "IMAGENAME eq java*"]) - .status(); + { + use std::os::windows::process::CommandExt; + const CREATE_NO_WINDOW: u32 = 0x08000000; + + let _ = std::process::Command::new("taskkill") + .args(["/F", "/FI", "IMAGENAME eq java.exe"]) + .creation_flags(CREATE_NO_WINDOW) + .status(); + + // Poll until no java.exe remains (up to ~3 s) so the installer can + // overwrite the JRE DLLs without hitting a sharing-violation error. + for _ in 0..30 { + let still_running = std::process::Command::new("tasklist") + .args(["/FI", "IMAGENAME eq java.exe", "/NH"]) + .creation_flags(CREATE_NO_WINDOW) + .output() + .map(|o| String::from_utf8_lossy(&o.stdout).contains("java.exe")) + .unwrap_or(false); + + if !still_running { + break; + } + std::thread::sleep(std::time::Duration::from_millis(100)); + } + } #[cfg(not(target_os = "windows"))] let _ = std::process::Command::new("pkill") @@ -131,6 +153,7 @@ fn kill_tachidesk(app: &tauri::AppHandle) { .status(); } + const DEFAULT_SERVER_CONF: &str = r#"server.ip = "127.0.0.1" server.port = 4567 server.webUIEnabled = false diff --git a/src/components/settings/Settings.svelte b/src/components/settings/Settings.svelte index d0f91c4..9ffdbb3 100644 --- a/src/components/settings/Settings.svelte +++ b/src/components/settings/Settings.svelte @@ -562,10 +562,9 @@ try { if (IS_WINDOWS) { - // Kill Suwayomi before installing — its JRE DLLs will be locked otherwise + // Kill Suwayomi before installing — its JRE DLLs will be locked otherwise. + // kill_server blocks on the Rust side until java.exe is fully gone. try { await invoke("kill_server"); } catch {} - // Give the process a moment to fully release file handles - await new Promise(res => setTimeout(res, 1500)); // Windows: Tauri updater downloads + runs passive NSIS installer await invoke("download_and_install_update"); updatePhase = "ready";