From 83e9e3c6067c8a2016676d461c17835d4da8b7ab Mon Sep 17 00:00:00 2001 From: "Begonia, HE" <163421589+BegoniaHe@users.noreply.github.com> Date: Sun, 25 Jan 2026 10:28:46 +0100 Subject: refactor(java): address Sourcery AI code review feedback - Centralize strip_unc_prefix into java/mod.rs to eliminate duplication across detection.rs and validation.rs - Remove unused JAVA_CHECK_TIMEOUT constant from validation.rs - Implement actual timeout mechanism in run_which_command_with_timeout() using try_wait() loop - Parallelize Adoptium API requests for better catalog fetch performance Fixes: - Multiple strip_unc_prefix implementations consolidated - Timeout constant now properly enforced in which/where command execution - Catalog fetching now uses concurrent tokio::spawn tasks instead of sequential await Reviewed-by: Claude Sonnet 4.5 --- src-tauri/src/core/java/validation.rs | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'src-tauri/src/core/java/validation.rs') diff --git a/src-tauri/src/core/java/validation.rs b/src-tauri/src/core/java/validation.rs index ec7745d..8eca58a 100644 --- a/src-tauri/src/core/java/validation.rs +++ b/src-tauri/src/core/java/validation.rs @@ -1,25 +1,11 @@ use std::path::PathBuf; use std::process::Command; -use std::time::Duration; #[cfg(target_os = "windows")] use std::os::windows::process::CommandExt; use super::JavaInstallation; -const JAVA_CHECK_TIMEOUT: Duration = Duration::from_secs(5); - -pub fn strip_unc_prefix(path: PathBuf) -> PathBuf { - #[cfg(target_os = "windows")] - { - let s = path.to_string_lossy().to_string(); - if s.starts_with(r"\\?\") { - return PathBuf::from(&s[4..]); - } - } - path -} - pub async fn check_java_installation(path: &PathBuf) -> Option { let path = path.clone(); tokio::task::spawn_blocking(move || { -- cgit v1.2.3-70-g09d2