Skip to content

Commit

Permalink
Fix forge format version 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Geometrically committed Aug 17, 2024
1 parent 0ae1e40 commit 93ae24e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
2 changes: 0 additions & 2 deletions daedalus/src/minecraft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Utc>,
/// The latest time a file in this version was updated
#[cfg_attr(feature = "bincode", bincode(with_serde))]
pub time: DateTime<Utc>,
#[serde(rename = "type")]
/// The type of version
Expand Down
17 changes: 9 additions & 8 deletions daedalus_client/src/forge.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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/",
)
Expand All @@ -414,19 +415,19 @@ async fn fetch(
&lib.name,
None,
vec![
url,
url.clone(),
"https://maven.creeperhost.net/"
.to_string(),
maven_url.to_string(),
],
false,
mirror_artifacts,
)?;

lib.url = Some(format_url("maven/"));
}
}

lib.url = Some(format_url("maven/"));

Ok(lib)
})
.collect::<Result<Vec<_>, Error>>()?,
Expand All @@ -442,7 +443,7 @@ async fn fetch(
// pub profile: String,
// pub version: String,
// pub json: String,
pub path: Option<String>,
// pub path: Option<String>,
// pub minecraft: String,
pub data: HashMap<String, daedalus::modded::SidedDataEntry>,
pub libraries: Vec<daedalus::minecraft::Library>,
Expand Down
2 changes: 1 addition & 1 deletion daedalus_client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ pub fn insert_mirrored_artifact(
entire_url: bool,
mirror_artifacts: &DashMap<String, MirrorArtifact>,
) -> Result<()> {
let mut val = mirror_artifacts
let val = mirror_artifacts
.entry(get_path_from_artifact(artifact)?)
.or_insert(MirrorArtifact {
sha1,
Expand Down
2 changes: 1 addition & 1 deletion daedalus_client/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 93ae24e

Please sign in to comment.