From 601fbdb9f143d9f1322ebb4acbfbc9b18eb6d60e Mon Sep 17 00:00:00 2001 From: Cat Core <34719527+arthurbambou@users.noreply.github.com> Date: Sat, 8 Apr 2023 21:28:10 +0200 Subject: [PATCH 1/6] Allow to reuse fabric code for fabric variants. --- daedalus_client/src/fabric.rs | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/daedalus_client/src/fabric.rs b/daedalus_client/src/fabric.rs index 6aa8f91..cdc3147 100644 --- a/daedalus_client/src/fabric.rs +++ b/daedalus_client/src/fabric.rs @@ -288,27 +288,36 @@ pub async fn retrieve_data( const FABRIC_META_URL: &str = "https://meta.fabricmc.net/v2"; -async fn fetch_fabric_version( +pub async fn fetch_fabric_like_version( version_number: &str, loader_version: &str, semaphore: Arc, + meta_url: &str, ) -> Result { Ok(serde_json::from_slice( &download_file( &format!( "{}/versions/loader/{}/{}/profile/json", - FABRIC_META_URL, version_number, loader_version + meta_url, version_number, loader_version ), None, semaphore, ) - .await?, + .await?, )?) } +async fn fetch_fabric_version( + version_number: &str, + loader_version: &str, + semaphore: Arc, +) -> Result { + fetch_fabric_like_version(version_number, loader_version, semaphore, FABRIC_META_URL).await +} + #[derive(Serialize, Deserialize, Debug, Clone)] /// Versions of fabric components -struct FabricVersions { +pub struct FabricVersions { /// Versions of Minecraft that fabric supports pub game: Vec, /// Available versions of the fabric loader @@ -317,7 +326,7 @@ struct FabricVersions { #[derive(Serialize, Deserialize, Debug, Clone)] /// A version of Minecraft that fabric supports -struct FabricGameVersion { +pub struct FabricGameVersion { /// The version number of the game pub version: String, /// Whether the Minecraft version is stable or not @@ -326,7 +335,7 @@ struct FabricGameVersion { #[derive(Serialize, Deserialize, Debug, Clone)] /// A version of the fabric loader -struct FabricLoaderVersion { +pub struct FabricLoaderVersion { /// The separator to get the build number pub separator: String, /// The build number @@ -339,16 +348,24 @@ struct FabricLoaderVersion { pub stable: bool, } /// Fetches the list of fabric versions -async fn fetch_fabric_versions( +pub async fn fetch_fabric_like_versions( url: Option<&str>, semaphore: Arc, + meta_url: &str, ) -> Result { Ok(serde_json::from_slice( &download_file( - url.unwrap_or(&*format!("{}/versions", FABRIC_META_URL)), + url.unwrap_or(&*format!("{}/versions", meta_url)), None, semaphore, ) .await?, )?) } + +async fn fetch_fabric_versions( + url: Option<&str>, + semaphore: Arc, +) -> Result { + fetch_fabric_like_versions(url, semaphore, FABRIC_META_URL).await +} From 344da32f61477315402c4ae769bc605a90835716 Mon Sep 17 00:00:00 2001 From: Cat Core <34719527+arthurbambou@users.noreply.github.com> Date: Sat, 8 Apr 2023 21:28:28 +0200 Subject: [PATCH 2/6] Add support for LegacyFabric --- daedalus/src/modded.rs | 4 +- daedalus_client/src/legacy_fabric.rs | 307 +++++++++++++++++++++++++++ daedalus_client/src/main.rs | 13 +- 3 files changed, 322 insertions(+), 2 deletions(-) create mode 100644 daedalus_client/src/legacy_fabric.rs diff --git a/daedalus/src/modded.rs b/daedalus/src/modded.rs index 2519719..601877c 100644 --- a/daedalus/src/modded.rs +++ b/daedalus/src/modded.rs @@ -12,7 +12,9 @@ use bincode::{Decode, Encode}; /// The latest version of the format the fabric model structs deserialize to pub const CURRENT_FABRIC_FORMAT_VERSION: usize = 0; -/// The latest version of the format the fabric model structs deserialize to +/// The latest version of the format the legacy-fabric model structs deserialize to +pub const CURRENT_LEGACY_FABRIC_FORMAT_VERSION: usize = 0; +/// The latest version of the format the forge model structs deserialize to pub const CURRENT_FORGE_FORMAT_VERSION: usize = 0; /// The dummy replace string library names, inheritsFrom, and version names should be replaced with diff --git a/daedalus_client/src/legacy_fabric.rs b/daedalus_client/src/legacy_fabric.rs new file mode 100644 index 0000000..7c5de6f --- /dev/null +++ b/daedalus_client/src/legacy_fabric.rs @@ -0,0 +1,307 @@ +use std::sync::Arc; +use tokio::sync::Semaphore; +use daedalus::modded::PartialVersionInfo; +use crate::fabric::{FabricVersions, fetch_fabric_like_version, fetch_fabric_like_versions}; +use crate::{download_file, format_url, upload_file_to_bucket, Error}; +use daedalus::minecraft::{Library, VersionManifest}; +use daedalus::modded::{ + LoaderVersion, Manifest, Version, DUMMY_REPLACE_STRING, +}; +use serde::{Deserialize, Serialize}; +use tokio::sync::{Mutex, RwLock}; + +const LEGACY_FABRIC_META_URL: &str = "https://meta.legacyfabric.net/v2"; + +pub async fn retrieve_data( + minecraft_versions: &VersionManifest, + uploaded_files: &mut Vec, + semaphore: Arc, +) -> Result<(), Error> { + let mut list = fetch_legacy_fabric_versions(None, semaphore.clone()).await?; + let old_manifest = daedalus::modded::fetch_manifest(&format_url(&format!( + "legacy-fabric/v{}/manifest.json", + daedalus::modded::CURRENT_LEGACY_FABRIC_FORMAT_VERSION, + ))) + .await + .ok(); + + let mut versions = if let Some(old_manifest) = old_manifest { + old_manifest.game_versions + } else { + Vec::new() + }; + + let loaders_mutex = RwLock::new(Vec::new()); + + { + let mut loaders = loaders_mutex.write().await; + + for loader in &list.loader { + loaders.push((Box::new(loader.stable), loader.version.clone())) + } + + list.loader + .retain(|x| loaders.iter().any(|val| val.1 == x.version)) + } + + const DUMMY_GAME_VERSION: &str = "1.8.9"; + + let loader_version_mutex = Mutex::new(Vec::new()); + let uploaded_files_mutex = Arc::new(Mutex::new(Vec::new())); + + let loader_versions = futures::future::try_join_all( + loaders_mutex.read().await.clone().into_iter().map( + |(stable, loader)| async { + { + if versions.iter().any(|x| { + x.id == DUMMY_REPLACE_STRING + && x.loaders.iter().any(|x| x.id == loader) + }) { + return Ok(None); + } + } + + let version = fetch_legacy_fabric_version( + DUMMY_GAME_VERSION, + &loader, + semaphore.clone(), + ) + .await?; + + Ok::, String, PartialVersionInfo)>, Error>( + Some((stable, loader, version)), + ) + }, + ), + ) + .await?; + + let visited_artifacts_mutex = Arc::new(Mutex::new(Vec::new())); + futures::future::try_join_all(loader_versions.into_iter() + .flatten().map( + |(stable, loader, version)| async { + let libs = futures::future::try_join_all( + version.libraries.into_iter().map(|mut lib| async { + { + let mut visited_assets = + visited_artifacts_mutex.lock().await; + + if visited_assets.contains(&lib.name) { + lib.name = lib.name.replace(DUMMY_GAME_VERSION, DUMMY_REPLACE_STRING); + lib.url = Some(format_url("maven/")); + + return Ok(lib); + } else { + visited_assets.push(lib.name.clone()) + } + } + + if lib.name.contains(DUMMY_GAME_VERSION) { + lib.name = lib.name.replace(DUMMY_GAME_VERSION, DUMMY_REPLACE_STRING); + futures::future::try_join_all(list.game.clone().into_iter().map(|game_version| async { + let semaphore = semaphore.clone(); + let uploaded_files_mutex = uploaded_files_mutex.clone(); + let lib_name = lib.name.clone(); + let lib_url = lib.url.clone(); + + async move { + let artifact_path = + daedalus::get_path_from_artifact(&lib_name.replace(DUMMY_REPLACE_STRING, &game_version.version))?; + + let artifact = download_file( + &format!( + "{}{}", + lib_url.unwrap_or_else(|| { + "https://maven.fabricmc.net/".to_string() + }), + artifact_path + ), + None, + semaphore.clone(), + ) + .await?; + + upload_file_to_bucket( + format!("{}/{}", "maven", artifact_path), + artifact.to_vec(), + Some("application/java-archive".to_string()), + &uploaded_files_mutex, + semaphore.clone(), + ) + .await?; + + Ok::<(), Error>(()) + }.await?; + + Ok::<(), Error>(()) + })).await?; + lib.url = Some(format_url("maven/")); + + return Ok(lib); + } + + let artifact_path = + daedalus::get_path_from_artifact(&lib.name)?; + + let artifact = download_file( + &format!( + "{}{}", + lib.url.unwrap_or_else(|| { + "https://maven.fabricmc.net/".to_string() + }), + artifact_path + ), + None, + semaphore.clone(), + ) + .await?; + + lib.url = Some(format_url("maven/")); + + upload_file_to_bucket( + format!("{}/{}", "maven", artifact_path), + artifact.to_vec(), + Some("application/java-archive".to_string()), + &uploaded_files_mutex, + semaphore.clone(), + ) + .await?; + + Ok::(lib) + }), + ) + .await?; + + let version_path = format!( + "legacy-fabric/v{}/versions/{}.json", + daedalus::modded::CURRENT_LEGACY_FABRIC_FORMAT_VERSION, + &loader + ); + + upload_file_to_bucket( + version_path.clone(), + serde_json::to_vec(&PartialVersionInfo { + arguments: version.arguments, + id: version + .id + .replace(DUMMY_GAME_VERSION, DUMMY_REPLACE_STRING), + main_class: version.main_class, + release_time: version.release_time, + time: version.time, + type_: version.type_, + inherits_from: version + .inherits_from + .replace(DUMMY_GAME_VERSION, DUMMY_REPLACE_STRING), + libraries: libs, + minecraft_arguments: version.minecraft_arguments, + processors: None, + data: None, + })?, + Some("application/json".to_string()), + &uploaded_files_mutex, + semaphore.clone(), + ) + .await?; + + { + let mut loader_version_map = loader_version_mutex.lock().await; + async move { + loader_version_map.push(LoaderVersion { + id: loader.to_string(), + url: format_url(&version_path), + stable: *stable, + }); + } + .await; + } + + Ok::<(), Error>(()) + }, + )) + .await?; + + versions.push(Version { + id: DUMMY_REPLACE_STRING.to_string(), + stable: true, + loaders: loader_version_mutex.into_inner(), + }); + + for version in &list.game { + versions.push(Version { + id: version.version.clone(), + stable: version.stable, + loaders: vec![], + }); + } + + versions.sort_by(|x, y| { + minecraft_versions + .versions + .iter() + .position(|z| x.id == z.id) + .unwrap_or_default() + .cmp( + &minecraft_versions + .versions + .iter() + .position(|z| y.id == z.id) + .unwrap_or_default(), + ) + }); + + for version in &mut versions { + version.loaders.sort_by(|x, y| { + list.loader + .iter() + .position(|z| { + x.id.split('-').next().unwrap_or_default() == &*z.version + }) + .unwrap_or_default() + .cmp( + &list + .loader + .iter() + .position(|z| { + y.id.split('-').next().unwrap_or_default() + == z.version + }) + .unwrap_or_default(), + ) + }) + } + + upload_file_to_bucket( + format!( + "legacy-fabric/v{}/manifest.json", + daedalus::modded::CURRENT_LEGACY_FABRIC_FORMAT_VERSION, + ), + serde_json::to_vec(&Manifest { + game_versions: versions, + })?, + Some("application/json".to_string()), + &uploaded_files_mutex, + semaphore, + ) + .await?; + + if let Ok(uploaded_files_mutex) = Arc::try_unwrap(uploaded_files_mutex) { + uploaded_files.extend(uploaded_files_mutex.into_inner()); + } + + Ok(()) +} + +async fn fetch_legacy_fabric_version( + version_number: &str, + loader_version: &str, + semaphore: Arc, +) -> Result { + fetch_fabric_like_version(version_number, loader_version, semaphore, LEGACY_FABRIC_META_URL).await +} + +async fn fetch_legacy_fabric_versions( + url: Option<&str>, + semaphore: Arc, +) -> Result { + fetch_fabric_like_versions(url, semaphore, LEGACY_FABRIC_META_URL).await +} \ No newline at end of file diff --git a/daedalus_client/src/main.rs b/daedalus_client/src/main.rs index 92fee4c..1284bd7 100644 --- a/daedalus_client/src/main.rs +++ b/daedalus_client/src/main.rs @@ -7,6 +7,7 @@ use std::time::Duration; use tokio::sync::Semaphore; mod fabric; +mod legacy_fabric; mod forge; mod minecraft; @@ -72,7 +73,17 @@ async fn main() { &mut uploaded_files, semaphore.clone(), ) - .await + .await + { + Ok(..) => {} + Err(err) => error!("{:?}", err), + }; + match legacy_fabric::retrieve_data( + &manifest, + &mut uploaded_files, + semaphore.clone(), + ) + .await { Ok(..) => {} Err(err) => error!("{:?}", err), From bb5367c9ccf78f59f719f45acba7b1050a4b8e90 Mon Sep 17 00:00:00 2001 From: Cat Core <34719527+arthurbambou@users.noreply.github.com> Date: Sat, 8 Apr 2023 21:35:55 +0200 Subject: [PATCH 3/6] Add support for Babric --- daedalus/src/modded.rs | 2 + daedalus_client/src/babric.rs | 307 ++++++++++++++++++++++++++++++++++ daedalus_client/src/main.rs | 11 ++ 3 files changed, 320 insertions(+) create mode 100644 daedalus_client/src/babric.rs diff --git a/daedalus/src/modded.rs b/daedalus/src/modded.rs index 601877c..e360931 100644 --- a/daedalus/src/modded.rs +++ b/daedalus/src/modded.rs @@ -14,6 +14,8 @@ use bincode::{Decode, Encode}; pub const CURRENT_FABRIC_FORMAT_VERSION: usize = 0; /// The latest version of the format the legacy-fabric model structs deserialize to pub const CURRENT_LEGACY_FABRIC_FORMAT_VERSION: usize = 0; +/// The latest version of the format the babric model structs deserialize to +pub const CURRENT_BABRIC_FORMAT_VERSION: usize = 0; /// The latest version of the format the forge model structs deserialize to pub const CURRENT_FORGE_FORMAT_VERSION: usize = 0; diff --git a/daedalus_client/src/babric.rs b/daedalus_client/src/babric.rs new file mode 100644 index 0000000..c5cb48b --- /dev/null +++ b/daedalus_client/src/babric.rs @@ -0,0 +1,307 @@ +use std::sync::Arc; +use tokio::sync::Semaphore; +use daedalus::modded::PartialVersionInfo; +use crate::fabric::{FabricVersions, fetch_fabric_like_version, fetch_fabric_like_versions}; +use crate::{download_file, format_url, upload_file_to_bucket, Error}; +use daedalus::minecraft::{Library, VersionManifest}; +use daedalus::modded::{ + LoaderVersion, Manifest, Version, DUMMY_REPLACE_STRING, +}; +use serde::{Deserialize, Serialize}; +use tokio::sync::{Mutex, RwLock}; + +const BABRIC_META_URL: &str = "https://meta.babric.glass-launcher.net/v2"; + +pub async fn retrieve_data( + minecraft_versions: &VersionManifest, + uploaded_files: &mut Vec, + semaphore: Arc, +) -> Result<(), Error> { + let mut list = fetch_babric_versions(None, semaphore.clone()).await?; + let old_manifest = daedalus::modded::fetch_manifest(&format_url(&format!( + "babric/v{}/manifest.json", + daedalus::modded::CURRENT_BABRIC_FORMAT_VERSION, + ))) + .await + .ok(); + + let mut versions = if let Some(old_manifest) = old_manifest { + old_manifest.game_versions + } else { + Vec::new() + }; + + let loaders_mutex = RwLock::new(Vec::new()); + + { + let mut loaders = loaders_mutex.write().await; + + for loader in &list.loader { + loaders.push((Box::new(loader.stable), loader.version.clone())) + } + + list.loader + .retain(|x| loaders.iter().any(|val| val.1 == x.version)) + } + + const DUMMY_GAME_VERSION: &str = "b1.7.3"; + + let loader_version_mutex = Mutex::new(Vec::new()); + let uploaded_files_mutex = Arc::new(Mutex::new(Vec::new())); + + let loader_versions = futures::future::try_join_all( + loaders_mutex.read().await.clone().into_iter().map( + |(stable, loader)| async { + { + if versions.iter().any(|x| { + x.id == DUMMY_REPLACE_STRING + && x.loaders.iter().any(|x| x.id == loader) + }) { + return Ok(None); + } + } + + let version = fetch_babric_version( + DUMMY_GAME_VERSION, + &loader, + semaphore.clone(), + ) + .await?; + + Ok::, String, PartialVersionInfo)>, Error>( + Some((stable, loader, version)), + ) + }, + ), + ) + .await?; + + let visited_artifacts_mutex = Arc::new(Mutex::new(Vec::new())); + futures::future::try_join_all(loader_versions.into_iter() + .flatten().map( + |(stable, loader, version)| async { + let libs = futures::future::try_join_all( + version.libraries.into_iter().map(|mut lib| async { + { + let mut visited_assets = + visited_artifacts_mutex.lock().await; + + if visited_assets.contains(&lib.name) { + lib.name = lib.name.replace(DUMMY_GAME_VERSION, DUMMY_REPLACE_STRING); + lib.url = Some(format_url("maven/")); + + return Ok(lib); + } else { + visited_assets.push(lib.name.clone()) + } + } + + if lib.name.contains(DUMMY_GAME_VERSION) { + lib.name = lib.name.replace(DUMMY_GAME_VERSION, DUMMY_REPLACE_STRING); + futures::future::try_join_all(list.game.clone().into_iter().map(|game_version| async { + let semaphore = semaphore.clone(); + let uploaded_files_mutex = uploaded_files_mutex.clone(); + let lib_name = lib.name.clone(); + let lib_url = lib.url.clone(); + + async move { + let artifact_path = + daedalus::get_path_from_artifact(&lib_name.replace(DUMMY_REPLACE_STRING, &game_version.version))?; + + let artifact = download_file( + &format!( + "{}{}", + lib_url.unwrap_or_else(|| { + "https://maven.glass-launcher.net/babric/".to_string() + }), + artifact_path + ), + None, + semaphore.clone(), + ) + .await?; + + upload_file_to_bucket( + format!("{}/{}", "maven", artifact_path), + artifact.to_vec(), + Some("application/java-archive".to_string()), + &uploaded_files_mutex, + semaphore.clone(), + ) + .await?; + + Ok::<(), Error>(()) + }.await?; + + Ok::<(), Error>(()) + })).await?; + lib.url = Some(format_url("maven/")); + + return Ok(lib); + } + + let artifact_path = + daedalus::get_path_from_artifact(&lib.name)?; + + let artifact = download_file( + &format!( + "{}{}", + lib.url.unwrap_or_else(|| { + "https://maven.glass-launcher.net/babric/".to_string() + }), + artifact_path + ), + None, + semaphore.clone(), + ) + .await?; + + lib.url = Some(format_url("maven/")); + + upload_file_to_bucket( + format!("{}/{}", "maven", artifact_path), + artifact.to_vec(), + Some("application/java-archive".to_string()), + &uploaded_files_mutex, + semaphore.clone(), + ) + .await?; + + Ok::(lib) + }), + ) + .await?; + + let version_path = format!( + "babric/v{}/versions/{}.json", + daedalus::modded::CURRENT_BABRIC_FORMAT_VERSION, + &loader + ); + + upload_file_to_bucket( + version_path.clone(), + serde_json::to_vec(&PartialVersionInfo { + arguments: version.arguments, + id: version + .id + .replace(DUMMY_GAME_VERSION, DUMMY_REPLACE_STRING), + main_class: version.main_class, + release_time: version.release_time, + time: version.time, + type_: version.type_, + inherits_from: version + .inherits_from + .replace(DUMMY_GAME_VERSION, DUMMY_REPLACE_STRING), + libraries: libs, + minecraft_arguments: version.minecraft_arguments, + processors: None, + data: None, + })?, + Some("application/json".to_string()), + &uploaded_files_mutex, + semaphore.clone(), + ) + .await?; + + { + let mut loader_version_map = loader_version_mutex.lock().await; + async move { + loader_version_map.push(LoaderVersion { + id: loader.to_string(), + url: format_url(&version_path), + stable: *stable, + }); + } + .await; + } + + Ok::<(), Error>(()) + }, + )) + .await?; + + versions.push(Version { + id: DUMMY_REPLACE_STRING.to_string(), + stable: true, + loaders: loader_version_mutex.into_inner(), + }); + + for version in &list.game { + versions.push(Version { + id: version.version.clone(), + stable: version.stable, + loaders: vec![], + }); + } + + versions.sort_by(|x, y| { + minecraft_versions + .versions + .iter() + .position(|z| x.id == z.id) + .unwrap_or_default() + .cmp( + &minecraft_versions + .versions + .iter() + .position(|z| y.id == z.id) + .unwrap_or_default(), + ) + }); + + for version in &mut versions { + version.loaders.sort_by(|x, y| { + list.loader + .iter() + .position(|z| { + x.id.split('-').next().unwrap_or_default() == &*z.version + }) + .unwrap_or_default() + .cmp( + &list + .loader + .iter() + .position(|z| { + y.id.split('-').next().unwrap_or_default() + == z.version + }) + .unwrap_or_default(), + ) + }) + } + + upload_file_to_bucket( + format!( + "babric/v{}/manifest.json", + daedalus::modded::CURRENT_BABRIC_FORMAT_VERSION, + ), + serde_json::to_vec(&Manifest { + game_versions: versions, + })?, + Some("application/json".to_string()), + &uploaded_files_mutex, + semaphore, + ) + .await?; + + if let Ok(uploaded_files_mutex) = Arc::try_unwrap(uploaded_files_mutex) { + uploaded_files.extend(uploaded_files_mutex.into_inner()); + } + + Ok(()) +} + +async fn fetch_babric_version( + version_number: &str, + loader_version: &str, + semaphore: Arc, +) -> Result { + fetch_fabric_like_version(version_number, loader_version, semaphore, BABRIC_META_URL).await +} + +async fn fetch_babric_versions( + url: Option<&str>, + semaphore: Arc, +) -> Result { + fetch_fabric_like_versions(url, semaphore, BABRIC_META_URL).await +} \ No newline at end of file diff --git a/daedalus_client/src/main.rs b/daedalus_client/src/main.rs index 1284bd7..8103f4f 100644 --- a/daedalus_client/src/main.rs +++ b/daedalus_client/src/main.rs @@ -8,6 +8,7 @@ use tokio::sync::Semaphore; mod fabric; mod legacy_fabric; +mod babric; mod forge; mod minecraft; @@ -88,6 +89,16 @@ async fn main() { Ok(..) => {} Err(err) => error!("{:?}", err), }; + match babric::retrieve_data( + &manifest, + &mut uploaded_files, + semaphore.clone(), + ) + .await + { + Ok(..) => {} + Err(err) => error!("{:?}", err), + }; match forge::retrieve_data( &manifest, &mut uploaded_files, From 72b115ce990dfafaa88eaab2f61f466f9b3013cd Mon Sep 17 00:00:00 2001 From: Cat Core <34719527+arthurbambou@users.noreply.github.com> Date: Sat, 8 Apr 2023 21:38:33 +0200 Subject: [PATCH 4/6] fix legacy fabric maven url --- daedalus_client/src/legacy_fabric.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/daedalus_client/src/legacy_fabric.rs b/daedalus_client/src/legacy_fabric.rs index 7c5de6f..5aeeb85 100644 --- a/daedalus_client/src/legacy_fabric.rs +++ b/daedalus_client/src/legacy_fabric.rs @@ -112,7 +112,7 @@ pub async fn retrieve_data( &format!( "{}{}", lib_url.unwrap_or_else(|| { - "https://maven.fabricmc.net/".to_string() + "https://repo.legacyfabric.net/repository/legacyfabric/".to_string() }), artifact_path ), @@ -147,7 +147,7 @@ pub async fn retrieve_data( &format!( "{}{}", lib.url.unwrap_or_else(|| { - "https://maven.fabricmc.net/".to_string() + "https://repo.legacyfabric.net/repository/legacyfabric/".to_string() }), artifact_path ), From 2332a8d60e0879dd593efe4db20d38a8ce6195c0 Mon Sep 17 00:00:00 2001 From: Cat Core <34719527+arthurbambou@users.noreply.github.com> Date: Sat, 8 Apr 2023 21:39:13 +0200 Subject: [PATCH 5/6] fmt --- daedalus_client/src/babric.rs | 30 +++++++++++++++---------- daedalus_client/src/fabric.rs | 10 +++++++-- daedalus_client/src/legacy_fabric.rs | 33 ++++++++++++++++++---------- daedalus_client/src/main.rs | 10 ++++----- 4 files changed, 53 insertions(+), 30 deletions(-) diff --git a/daedalus_client/src/babric.rs b/daedalus_client/src/babric.rs index c5cb48b..f398015 100644 --- a/daedalus_client/src/babric.rs +++ b/daedalus_client/src/babric.rs @@ -1,13 +1,15 @@ -use std::sync::Arc; -use tokio::sync::Semaphore; -use daedalus::modded::PartialVersionInfo; -use crate::fabric::{FabricVersions, fetch_fabric_like_version, fetch_fabric_like_versions}; +use crate::fabric::{ + fetch_fabric_like_version, fetch_fabric_like_versions, FabricVersions, +}; use crate::{download_file, format_url, upload_file_to_bucket, Error}; use daedalus::minecraft::{Library, VersionManifest}; +use daedalus::modded::PartialVersionInfo; use daedalus::modded::{ LoaderVersion, Manifest, Version, DUMMY_REPLACE_STRING, }; use serde::{Deserialize, Serialize}; +use std::sync::Arc; +use tokio::sync::Semaphore; use tokio::sync::{Mutex, RwLock}; const BABRIC_META_URL: &str = "https://meta.babric.glass-launcher.net/v2"; @@ -22,8 +24,8 @@ pub async fn retrieve_data( "babric/v{}/manifest.json", daedalus::modded::CURRENT_BABRIC_FORMAT_VERSION, ))) - .await - .ok(); + .await + .ok(); let mut versions = if let Some(old_manifest) = old_manifest { old_manifest.game_versions @@ -66,7 +68,7 @@ pub async fn retrieve_data( &loader, semaphore.clone(), ) - .await?; + .await?; Ok::, String, PartialVersionInfo)>, Error>( Some((stable, loader, version)), @@ -74,7 +76,7 @@ pub async fn retrieve_data( }, ), ) - .await?; + .await?; let visited_artifacts_mutex = Arc::new(Mutex::new(Vec::new())); futures::future::try_join_all(loader_versions.into_iter() @@ -282,7 +284,7 @@ pub async fn retrieve_data( &uploaded_files_mutex, semaphore, ) - .await?; + .await?; if let Ok(uploaded_files_mutex) = Arc::try_unwrap(uploaded_files_mutex) { uploaded_files.extend(uploaded_files_mutex.into_inner()); @@ -296,7 +298,13 @@ async fn fetch_babric_version( loader_version: &str, semaphore: Arc, ) -> Result { - fetch_fabric_like_version(version_number, loader_version, semaphore, BABRIC_META_URL).await + fetch_fabric_like_version( + version_number, + loader_version, + semaphore, + BABRIC_META_URL, + ) + .await } async fn fetch_babric_versions( @@ -304,4 +312,4 @@ async fn fetch_babric_versions( semaphore: Arc, ) -> Result { fetch_fabric_like_versions(url, semaphore, BABRIC_META_URL).await -} \ No newline at end of file +} diff --git a/daedalus_client/src/fabric.rs b/daedalus_client/src/fabric.rs index cdc3147..1fa67ed 100644 --- a/daedalus_client/src/fabric.rs +++ b/daedalus_client/src/fabric.rs @@ -303,7 +303,7 @@ pub async fn fetch_fabric_like_version( None, semaphore, ) - .await?, + .await?, )?) } @@ -312,7 +312,13 @@ async fn fetch_fabric_version( loader_version: &str, semaphore: Arc, ) -> Result { - fetch_fabric_like_version(version_number, loader_version, semaphore, FABRIC_META_URL).await + fetch_fabric_like_version( + version_number, + loader_version, + semaphore, + FABRIC_META_URL, + ) + .await } #[derive(Serialize, Deserialize, Debug, Clone)] diff --git a/daedalus_client/src/legacy_fabric.rs b/daedalus_client/src/legacy_fabric.rs index 5aeeb85..f11f43c 100644 --- a/daedalus_client/src/legacy_fabric.rs +++ b/daedalus_client/src/legacy_fabric.rs @@ -1,13 +1,15 @@ -use std::sync::Arc; -use tokio::sync::Semaphore; -use daedalus::modded::PartialVersionInfo; -use crate::fabric::{FabricVersions, fetch_fabric_like_version, fetch_fabric_like_versions}; +use crate::fabric::{ + fetch_fabric_like_version, fetch_fabric_like_versions, FabricVersions, +}; use crate::{download_file, format_url, upload_file_to_bucket, Error}; use daedalus::minecraft::{Library, VersionManifest}; +use daedalus::modded::PartialVersionInfo; use daedalus::modded::{ LoaderVersion, Manifest, Version, DUMMY_REPLACE_STRING, }; use serde::{Deserialize, Serialize}; +use std::sync::Arc; +use tokio::sync::Semaphore; use tokio::sync::{Mutex, RwLock}; const LEGACY_FABRIC_META_URL: &str = "https://meta.legacyfabric.net/v2"; @@ -17,13 +19,14 @@ pub async fn retrieve_data( uploaded_files: &mut Vec, semaphore: Arc, ) -> Result<(), Error> { - let mut list = fetch_legacy_fabric_versions(None, semaphore.clone()).await?; + let mut list = + fetch_legacy_fabric_versions(None, semaphore.clone()).await?; let old_manifest = daedalus::modded::fetch_manifest(&format_url(&format!( "legacy-fabric/v{}/manifest.json", daedalus::modded::CURRENT_LEGACY_FABRIC_FORMAT_VERSION, ))) - .await - .ok(); + .await + .ok(); let mut versions = if let Some(old_manifest) = old_manifest { old_manifest.game_versions @@ -66,7 +69,7 @@ pub async fn retrieve_data( &loader, semaphore.clone(), ) - .await?; + .await?; Ok::, String, PartialVersionInfo)>, Error>( Some((stable, loader, version)), @@ -74,7 +77,7 @@ pub async fn retrieve_data( }, ), ) - .await?; + .await?; let visited_artifacts_mutex = Arc::new(Mutex::new(Vec::new())); futures::future::try_join_all(loader_versions.into_iter() @@ -282,7 +285,7 @@ pub async fn retrieve_data( &uploaded_files_mutex, semaphore, ) - .await?; + .await?; if let Ok(uploaded_files_mutex) = Arc::try_unwrap(uploaded_files_mutex) { uploaded_files.extend(uploaded_files_mutex.into_inner()); @@ -296,7 +299,13 @@ async fn fetch_legacy_fabric_version( loader_version: &str, semaphore: Arc, ) -> Result { - fetch_fabric_like_version(version_number, loader_version, semaphore, LEGACY_FABRIC_META_URL).await + fetch_fabric_like_version( + version_number, + loader_version, + semaphore, + LEGACY_FABRIC_META_URL, + ) + .await } async fn fetch_legacy_fabric_versions( @@ -304,4 +313,4 @@ async fn fetch_legacy_fabric_versions( semaphore: Arc, ) -> Result { fetch_fabric_like_versions(url, semaphore, LEGACY_FABRIC_META_URL).await -} \ No newline at end of file +} diff --git a/daedalus_client/src/main.rs b/daedalus_client/src/main.rs index 8103f4f..34ec8f0 100644 --- a/daedalus_client/src/main.rs +++ b/daedalus_client/src/main.rs @@ -6,10 +6,10 @@ use std::sync::Arc; use std::time::Duration; use tokio::sync::Semaphore; -mod fabric; -mod legacy_fabric; mod babric; +mod fabric; mod forge; +mod legacy_fabric; mod minecraft; #[derive(thiserror::Error, Debug)] @@ -74,7 +74,7 @@ async fn main() { &mut uploaded_files, semaphore.clone(), ) - .await + .await { Ok(..) => {} Err(err) => error!("{:?}", err), @@ -84,7 +84,7 @@ async fn main() { &mut uploaded_files, semaphore.clone(), ) - .await + .await { Ok(..) => {} Err(err) => error!("{:?}", err), @@ -94,7 +94,7 @@ async fn main() { &mut uploaded_files, semaphore.clone(), ) - .await + .await { Ok(..) => {} Err(err) => error!("{:?}", err), From e6ecf48727e50290671ded98dbb50c23e91faab4 Mon Sep 17 00:00:00 2001 From: Cat Core <34719527+arthurbambou@users.noreply.github.com> Date: Sat, 8 Apr 2023 21:41:29 +0200 Subject: [PATCH 6/6] clippy --- daedalus_client/src/babric.rs | 1 - daedalus_client/src/legacy_fabric.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/daedalus_client/src/babric.rs b/daedalus_client/src/babric.rs index f398015..4383f1e 100644 --- a/daedalus_client/src/babric.rs +++ b/daedalus_client/src/babric.rs @@ -7,7 +7,6 @@ use daedalus::modded::PartialVersionInfo; use daedalus::modded::{ LoaderVersion, Manifest, Version, DUMMY_REPLACE_STRING, }; -use serde::{Deserialize, Serialize}; use std::sync::Arc; use tokio::sync::Semaphore; use tokio::sync::{Mutex, RwLock}; diff --git a/daedalus_client/src/legacy_fabric.rs b/daedalus_client/src/legacy_fabric.rs index f11f43c..6f8c3ce 100644 --- a/daedalus_client/src/legacy_fabric.rs +++ b/daedalus_client/src/legacy_fabric.rs @@ -7,7 +7,6 @@ use daedalus::modded::PartialVersionInfo; use daedalus::modded::{ LoaderVersion, Manifest, Version, DUMMY_REPLACE_STRING, }; -use serde::{Deserialize, Serialize}; use std::sync::Arc; use tokio::sync::Semaphore; use tokio::sync::{Mutex, RwLock};