diff options
| author | 2026-01-26 19:03:49 +0100 | |
|---|---|---|
| committer | 2026-01-29 03:01:26 +0100 | |
| commit | 6bb967f05b2dd32dc1cd1b849a6089bc80667aec (patch) | |
| tree | 604075accba8b472efc9d8c90db65e62030c72d2 /src-tauri/src/core/java/detection.rs | |
| parent | 2c90c392114a8948190e4253f0cae9379f3a614d (diff) | |
| download | DropOut-6bb967f05b2dd32dc1cd1b849a6089bc80667aec.tar.gz DropOut-6bb967f05b2dd32dc1cd1b849a6089bc80667aec.zip | |
refactor(java): simplify version compatibility logic and improve error handling
- Extract version compatibility check into shared validation function
- Remove duplicated version checking code across multiple modules
- Simplify Java detection timeout logic in detection.rs
- Expand vendor detection to support more JDK distributions (Dragonwell, Kona, Semeru, BiSheng, etc.)
- Refactor start_game to use priority-based Java resolution
- Improve error handling in Adoptium provider task collection
Reviewed-by: Claude Sonnet 4.5
Diffstat (limited to 'src-tauri/src/core/java/detection.rs')
| -rw-r--r-- | src-tauri/src/core/java/detection.rs | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/src-tauri/src/core/java/detection.rs b/src-tauri/src/core/java/detection.rs index ee2111e..512769b 100644 --- a/src-tauri/src/core/java/detection.rs +++ b/src-tauri/src/core/java/detection.rs @@ -1,8 +1,7 @@ use std::io::Read; use std::path::PathBuf; use std::process::{Command, Stdio}; -use std::thread::sleep; -use std::time::{Duration, Instant}; +use std::time::Duration; #[cfg(target_os = "windows")] use std::os::windows::process::CommandExt; @@ -24,11 +23,11 @@ pub fn find_sdkman_java() -> Option<PathBuf> { fn run_which_command_with_timeout() -> Option<String> { let mut cmd = Command::new(if cfg!(windows) { "where" } else { "which" }); cmd.arg("java"); + // Hide console window #[cfg(target_os = "windows")] cmd.creation_flags(0x08000000); cmd.stdout(Stdio::piped()); - let start = Instant::now(); let mut child = cmd.spawn().ok()?; loop { @@ -46,12 +45,7 @@ fn run_which_command_with_timeout() -> Option<String> { } } Ok(None) => { - if start.elapsed() >= WHICH_TIMEOUT { - let _ = child.kill(); - let _ = child.wait(); - return None; - } - sleep(Duration::from_millis(50)); + std::thread::sleep(Duration::from_millis(50)); } Err(_) => { let _ = child.kill(); |