aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src-tauri/src/main.rs
diff options
context:
space:
mode:
authorBegonia, HE <163421589+BegoniaHe@users.noreply.github.com>2026-01-25 04:52:35 +0100
committerBegonia, HE <163421589+BegoniaHe@users.noreply.github.com>2026-01-29 02:53:33 +0100
commitd7ddf3710f6aff40d0595430f5f49255c89fdca1 (patch)
treedad7408e179479393ea01bda57fbf3f0a9346de6 /src-tauri/src/main.rs
parenta17d94168440ce91703069fc6027dc766e0d8998 (diff)
downloadDropOut-d7ddf3710f6aff40d0595430f5f49255c89fdca1.tar.gz
DropOut-d7ddf3710f6aff40d0595430f5f49255c89fdca1.zip
refactor(java): modularize Java detection and management system
- Split monolithic java.rs (1089 lines) into focused modules - detection: Java installation discovery - validation: Version validation and requirements checking - priority: Installation selection priority logic - provider: Java download provider trait - providers: Provider implementations (Adoptium) - persistence: Cache and catalog management - Add java_path_override field to Instance struct for per-instance Java configuration - Export JavaInstallation at core module level This refactoring improves maintainability and prepares for multi-vendor Java provider support. Reviewed-by: Claude Sonnet 4.5
Diffstat (limited to 'src-tauri/src/main.rs')
-rw-r--r--src-tauri/src/main.rs20
1 files changed, 14 insertions, 6 deletions
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 45fa77b..5fa46b8 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -204,7 +204,7 @@ async fn start_game(
let mut java_path_to_use = config.java_path.clone();
if !java_path_to_use.is_empty() && java_path_to_use != "java" {
let is_compatible =
- core::java::is_java_compatible(&java_path_to_use, required_java_major, max_java_major);
+ core::java::is_java_compatible(&java_path_to_use, required_java_major, max_java_major).await;
if !is_compatible {
emit_log!(
@@ -216,7 +216,7 @@ async fn start_game(
// Try to find a compatible Java version
if let Some(compatible_java) =
- core::java::get_compatible_java(app_handle, required_java_major, max_java_major)
+ core::java::get_compatible_java(app_handle, required_java_major, max_java_major).await
{
emit_log!(
window,
@@ -252,7 +252,7 @@ async fn start_game(
} else {
// No Java configured, try to find a compatible one
if let Some(compatible_java) =
- core::java::get_compatible_java(app_handle, required_java_major, max_java_major)
+ core::java::get_compatible_java(app_handle, required_java_major, max_java_major).await
{
emit_log!(
window,
@@ -1556,10 +1556,18 @@ async fn refresh_account(
/// Detect Java installations on the system
#[tauri::command]
+async fn detect_all_java_installations(
+ app_handle: tauri::AppHandle,
+) -> Result<Vec<core::java::JavaInstallation>, String> {
+ Ok(core::java::detect_all_java_installations(&app_handle).await)
+}
+
+/// Alias for detect_all_java_installations (for backward compatibility)
+#[tauri::command]
async fn detect_java(
app_handle: tauri::AppHandle,
) -> Result<Vec<core::java::JavaInstallation>, String> {
- Ok(core::java::detect_all_java_installations(&app_handle))
+ Ok(core::java::detect_all_java_installations(&app_handle).await)
}
/// Get recommended Java for a specific Minecraft version
@@ -1567,7 +1575,7 @@ async fn detect_java(
async fn get_recommended_java(
required_major_version: Option<u64>,
) -> Result<Option<core::java::JavaInstallation>, String> {
- Ok(core::java::get_recommended_java(required_major_version))
+ Ok(core::java::get_recommended_java(required_major_version).await)
}
/// Get Adoptium Java download info
@@ -2065,7 +2073,7 @@ async fn install_forge(
config.java_path.clone()
} else {
// Try to find a suitable Java installation
- let javas = core::java::detect_all_java_installations(app_handle);
+ let javas = core::java::detect_all_java_installations(app_handle).await;
if let Some(java) = javas.first() {
java.path.clone()
} else {