From 93ae24e7075f992e0855bd7875f437507e51cd12 Mon Sep 17 00:00:00 2001 From: Jai A Date: Sat, 17 Aug 2024 13:28:00 -0700 Subject: [PATCH] Fix forge format version 1 --- daedalus/src/minecraft.rs | 2 -- daedalus_client/src/forge.rs | 17 +++++++++-------- daedalus_client/src/main.rs | 2 +- daedalus_client/src/util.rs | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/daedalus/src/minecraft.rs b/daedalus/src/minecraft.rs index 021c91ab7..e117052ad 100644 --- a/daedalus/src/minecraft.rs +++ b/daedalus/src/minecraft.rs @@ -430,10 +430,8 @@ pub struct VersionInfo { /// The minimum version of the Minecraft Launcher that can run this version of the game pub minimum_launcher_version: u32, /// The time that the version was released - #[cfg_attr(feature = "bincode", bincode(with_serde))] pub release_time: DateTime, /// The latest time a file in this version was updated - #[cfg_attr(feature = "bincode", bincode(with_serde))] pub time: DateTime, #[serde(rename = "type")] /// The type of version diff --git a/daedalus_client/src/forge.rs b/daedalus_client/src/forge.rs index 09c8e0aa6..a560b81aa 100644 --- a/daedalus_client/src/forge.rs +++ b/daedalus_client/src/forge.rs @@ -1,5 +1,5 @@ use crate::util::{ - download_file, fetch_json, fetch_xml, format_url, sha1_async, + download_file, fetch_json, fetch_xml, format_url, }; use crate::{insert_mirrored_artifact, Error, MirrorArtifact, UploadFile}; use chrono::{DateTime, Utc}; @@ -403,9 +403,10 @@ async fn fetch( .map(|mut lib| { // For all libraries besides the forge lib extracted, we mirror them from maven servers // unless the URL is empty/null or available on Minecraft's servers - if let Some(url) = lib.url { - if lib.name != install_profile.install.path - && !url.is_empty() + if let Some(ref url) = lib.url { + if lib.name == install_profile.install.path { + lib.url = Some(format_url("maven/")); + } else if !url.is_empty() && !url.contains( "https://libraries.minecraft.net/", ) @@ -414,7 +415,7 @@ async fn fetch( &lib.name, None, vec![ - url, + url.clone(), "https://maven.creeperhost.net/" .to_string(), maven_url.to_string(), @@ -422,11 +423,11 @@ async fn fetch( false, mirror_artifacts, )?; + + lib.url = Some(format_url("maven/")); } } - lib.url = Some(format_url("maven/")); - Ok(lib) }) .collect::, Error>>()?, @@ -442,7 +443,7 @@ async fn fetch( // pub profile: String, // pub version: String, // pub json: String, - pub path: Option, + // pub path: Option, // pub minecraft: String, pub data: HashMap, pub libraries: Vec, diff --git a/daedalus_client/src/main.rs b/daedalus_client/src/main.rs index 8e934cbd5..870a55ec0 100644 --- a/daedalus_client/src/main.rs +++ b/daedalus_client/src/main.rs @@ -160,7 +160,7 @@ pub fn insert_mirrored_artifact( entire_url: bool, mirror_artifacts: &DashMap, ) -> Result<()> { - let mut val = mirror_artifacts + let val = mirror_artifacts .entry(get_path_from_artifact(artifact)?) .or_insert(MirrorArtifact { sha1, diff --git a/daedalus_client/src/util.rs b/daedalus_client/src/util.rs index 72ff25575..b5e4b360a 100644 --- a/daedalus_client/src/util.rs +++ b/daedalus_client/src/util.rs @@ -159,7 +159,7 @@ pub async fn download_file( const RETRIES: u32 = 10; for attempt in 1..=(RETRIES + 1) { let result = REQWEST_CLIENT - .get(&url.replace("http://", "https://")) + .get(url.replace("http://", "https://")) .send() .await .and_then(|x| x.error_for_status());