no-mistakes(lint): fix(lint): rustfmt formatting in mods.rs

This commit is contained in:
objz committed 2026-04-25 14:25:04 +02:00
1 parent 9f463c80bc
commit 5dbb2be873
50 files changed
+624 -351

No files matched your search

+1 -2
View File
@@ -6,7 +6,7 @@ use std::path::Path;
use serde::{Deserialize, Serialize};
use crate::instance::loader::GameVersion;
use crate::net::{download_file, HttpClient, NetError};
use crate::net::{HttpClient, NetError, download_file};
use crate::tui::progress::set_sub_action;
const FABRIC_META_BASE: &str = "https://meta.fabricmc.net/v2";
@@ -152,5 +152,4 @@ mod tests {
Err(e) => panic!("fetch_fabric_game_versions failed: {}", e),
}
}
}
+20 -23
View File
@@ -87,10 +87,7 @@ pub async fn download_forge_installer(
let mut last_err = None;
for slug in &slugs {
let url = format!(
"{}/{slug}/forge-{slug}-installer.jar",
FORGE_MAVEN_BASE,
);
let url = format!("{}/{slug}/forge-{slug}-installer.jar", FORGE_MAVEN_BASE,);
match download_file(client, &url, dest, |downloaded, total| {
crate::tui::progress::set_progress(downloaded, total);
})
@@ -179,25 +176,23 @@ pub(crate) async fn install_forge_from_profile(
set_action("Installing legacy Forge from profile...");
let file = std::fs::File::open(installer_path)?;
let mut archive = zip::ZipArchive::new(file).map_err(|e| {
NetError::Parse(format!("Failed to open installer as ZIP: {e}"))
})?;
let mut archive = zip::ZipArchive::new(file)
.map_err(|e| NetError::Parse(format!("Failed to open installer as ZIP: {e}")))?;
let profile_data: serde_json::Value = {
let entry = archive.by_name("install_profile.json").map_err(|e| {
NetError::Parse(format!("install_profile.json not found in installer: {e}"))
})?;
serde_json::from_reader(entry).map_err(|e| {
NetError::Parse(format!("Failed to parse install_profile.json: {e}"))
})?
serde_json::from_reader(entry)
.map_err(|e| NetError::Parse(format!("Failed to parse install_profile.json: {e}")))?
};
let version_info = profile_data.get("versionInfo").ok_or_else(|| {
NetError::Parse("install_profile.json missing versionInfo".into())
})?;
let install_info = profile_data.get("install").ok_or_else(|| {
NetError::Parse("install_profile.json missing install section".into())
})?;
let version_info = profile_data
.get("versionInfo")
.ok_or_else(|| NetError::Parse("install_profile.json missing versionInfo".into()))?;
let install_info = profile_data
.get("install")
.ok_or_else(|| NetError::Parse("install_profile.json missing install section".into()))?;
let main_class = version_info
.get("mainClass")
@@ -221,9 +216,11 @@ pub(crate) async fn install_forge_from_profile(
.ok_or_else(|| NetError::Parse("missing install.path".into()))?;
// extract the universal jar to the correct maven location
let universal_maven_path = crate::net::maven_coord_to_path(install_path_coord)
.ok_or_else(|| {
NetError::Parse(format!("Invalid maven coord in install.path: {install_path_coord}"))
let universal_maven_path =
crate::net::maven_coord_to_path(install_path_coord).ok_or_else(|| {
NetError::Parse(format!(
"Invalid maven coord in install.path: {install_path_coord}"
))
})?;
set_sub_action("Extracting universal JAR...");
@@ -234,7 +231,9 @@ pub(crate) async fn install_forge_from_profile(
{
let mut entry = archive.by_name(file_path).map_err(|e| {
NetError::Parse(format!("Universal JAR '{file_path}' not found in installer: {e}"))
NetError::Parse(format!(
"Universal JAR '{file_path}' not found in installer: {e}"
))
})?;
let mut buf = Vec::new();
entry.read_to_end(&mut buf)?;
@@ -252,9 +251,7 @@ pub(crate) async fn install_forge_from_profile(
let maven_path = match crate::net::maven_coord_to_path(name) {
Some(p) => p,
None => {
return Err(NetError::Parse(format!(
"Invalid Maven coordinate: {name}"
)));
return Err(NetError::Parse(format!("Invalid Maven coordinate: {name}")));
}
};
+6 -1
View File
@@ -90,7 +90,12 @@ pub async fn download_file(
for attempt in 0..=MAX_RETRIES {
if attempt > 0 {
let delay = RETRY_BASE_DELAY_MS * 2u64.pow(attempt - 1);
tracing::warn!("retrying download (attempt {}/{}): {}", attempt + 1, MAX_RETRIES + 1, url);
tracing::warn!(
"retrying download (attempt {}/{}): {}",
attempt + 1,
MAX_RETRIES + 1,
url
);
tokio::time::sleep(std::time::Duration::from_millis(delay)).await;
}
+9 -3
View File
@@ -55,7 +55,9 @@ use crate::instance::models::ModLoader;
// mrpack dependencies use keys like "fabric-loader", "forge", etc.
// checks in priority order and returns the first match.
pub fn loader_from_dependencies(deps: &HashMap<String, String>) -> (Option<ModLoader>, Option<String>) {
pub fn loader_from_dependencies(
deps: &HashMap<String, String>,
) -> (Option<ModLoader>, Option<String>) {
let loaders = [
("fabric-loader", ModLoader::Fabric),
("forge", ModLoader::Forge),
@@ -108,7 +110,8 @@ pub async fn fetch_versions(
) -> Result<Vec<VersionInfo>, crate::net::NetError> {
let url = format!(
"{}/project/{}/version?loaders=[\"fabric\",\"forge\",\"neoforge\",\"quilt\"]",
API_BASE, url_encode(slug_or_id)
API_BASE,
url_encode(slug_or_id)
);
client.get_json(&url).await
}
@@ -187,7 +190,10 @@ mod tests {
fn game_version_from_deps() {
let mut deps = HashMap::new();
deps.insert("minecraft".to_string(), "1.21.4".to_string());
assert_eq!(game_version_from_dependencies(&deps), Some("1.21.4".to_string()));
assert_eq!(
game_version_from_dependencies(&deps),
Some("1.21.4".to_string())
);
}
#[test]