Skip to content
This repository was archived by the owner on Mar 14, 2026. It is now read-only.

Commit 50f600c

Browse files
committed
fix(launch): format java rs
1 parent 74bad53 commit 50f600c

1 file changed

Lines changed: 17 additions & 18 deletions

File tree

crates/core/src/launch/java.rs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::{env, fs, path::PathBuf};
22

3-
use crate::{errors::LaunchErrors, trait_alias::AsyncSendSync, HTTP::Client};
43
use super::download_files;
4+
use crate::{HTTP::Client, errors::LaunchErrors, trait_alias::AsyncSendSync};
55

66
/// Java Runtime Environment (JRE) for Minecraft.
77
#[derive(Debug, Clone)]
@@ -46,8 +46,6 @@ fn java_url(jre: JRE, version: &str) -> Option<String> {
4646
arch_url(urls)
4747
}
4848

49-
JRE::Zulu => todo!(),
50-
5149
JRE::GraalVM => {
5250
arch_support(&["x86_64", "x86", "aarch64"]).ok()?;
5351

@@ -71,6 +69,7 @@ fn java_url(jre: JRE, version: &str) -> Option<String> {
7169
];
7270
arch_url(urls)
7371
}
72+
JRE::Zulu => todo!(),
7473
}
7574
}
7675

@@ -92,7 +91,7 @@ pub fn get_java(
9291
};
9392

9493
let user_agent = user_agent.to_owned();
95-
let version = version.to_owned();
94+
let version = version.to_owned();
9695
let jre = jre.clone();
9796

9897
async move {
@@ -104,21 +103,19 @@ pub fn get_java(
104103
}
105104
}
106105

107-
108106
async fn download_jre(
109107
client: Client,
110108
url: String,
111109
path: PathBuf,
112110
user_agent: &str,
113111
) -> Result<(), LaunchErrors> {
114-
download_files(client.clone(), user_agent, &path, url).await.map_err(|e| {
115-
LaunchErrors::Requirements(format!("Failed to download JRE due to: {}", e))
116-
})?;
112+
download_files(client.clone(), user_agent, &path, url)
113+
.await
114+
.map_err(|e| LaunchErrors::Requirements(format!("Failed to download JRE due to: {}", e)))?;
117115

118116
if path.exists() && path.is_file() {
119-
fs::remove_file(&path).map_err(|e| {
120-
LaunchErrors::Requirements(format!("Failed to clean up file: {}", e))
121-
})?;
117+
fs::remove_file(&path)
118+
.map_err(|e| LaunchErrors::Requirements(format!("Failed to clean up file: {}", e)))?;
122119
}
123120

124121
Ok(())
@@ -128,13 +125,15 @@ fn arch_url(candidates: Vec<ArchUrl>) -> Option<String> {
128125
let arch = env::consts::ARCH;
129126
let os = env::consts::OS;
130127

131-
candidates.into_iter().find_map(|entry| match (entry.arch, entry.os) {
132-
(Some(a), Some(o)) if a == arch && o == os => Some(entry.url),
133-
(Some(a), None) if a == arch => Some(entry.url),
134-
(None, Some(o)) if o == os => Some(entry.url),
135-
(None, None) => Some(entry.url),
136-
_ => None,
137-
})
128+
candidates
129+
.into_iter()
130+
.find_map(|entry| match (entry.arch, entry.os) {
131+
(Some(a), Some(o)) if a == arch && o == os => Some(entry.url),
132+
(Some(a), None) if a == arch => Some(entry.url),
133+
(None, Some(o)) if o == os => Some(entry.url),
134+
(None, None) => Some(entry.url),
135+
_ => None,
136+
})
138137
}
139138

140139
fn arch_support(supported: &[&str]) -> Result<(), LaunchErrors> {

0 commit comments

Comments
 (0)