Fix forge format version 1

This commit is contained in:
Jai A 2024-08-17 13:28:00 -07:00
parent 0ae1e40d79
commit 93ae24e707
No known key found for this signature in database
GPG Key ID: 9A9F9B7250E9883C
4 changed files with 11 additions and 12 deletions

View File

@ -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

View File

@ -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::<Result<Vec<_>, Error>>()?,
@ -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>,

View File

@ -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,

View File

@ -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());