You've already forked AstralRinth
forked from didirus/AstralRinth
Support for ARM + Quilt
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
use crate::download_file;
|
||||
use crate::{format_url, upload_file_to_bucket, Error};
|
||||
use daedalus::minecraft::VersionManifest;
|
||||
use daedalus::minecraft::{Library, merge_partial_library, PartialLibrary, VersionManifest};
|
||||
use log::info;
|
||||
use std::sync::Arc;
|
||||
use std::time::Instant;
|
||||
use tokio::sync::{Mutex, Semaphore};
|
||||
use serde::Deserialize;
|
||||
use daedalus::get_hash;
|
||||
|
||||
pub async fn retrieve_data(
|
||||
uploaded_files: &mut Vec<String>,
|
||||
@@ -23,6 +25,9 @@ pub async fn retrieve_data(
|
||||
daedalus::minecraft::fetch_version_manifest(None).await?;
|
||||
let cloned_manifest = Arc::new(Mutex::new(manifest.clone()));
|
||||
|
||||
let patches = fetch_library_patches(None, semaphore.clone()).await?;
|
||||
let cloned_patches = Arc::new(&patches);
|
||||
|
||||
let visited_assets_mutex = Arc::new(Mutex::new(Vec::new()));
|
||||
let uploaded_files_mutex = Arc::new(Mutex::new(Vec::new()));
|
||||
|
||||
@@ -48,6 +53,7 @@ pub async fn retrieve_data(
|
||||
let cloned_manifest_mutex = Arc::clone(&cloned_manifest);
|
||||
let uploaded_files_mutex = Arc::clone(&uploaded_files_mutex);
|
||||
let semaphore = Arc::clone(&semaphore);
|
||||
let patches = Arc::clone(&cloned_patches);
|
||||
|
||||
let assets_hash =
|
||||
old_version.and_then(|x| x.assets_index_sha1.clone());
|
||||
@@ -55,9 +61,30 @@ pub async fn retrieve_data(
|
||||
async move {
|
||||
let mut upload_futures = Vec::new();
|
||||
|
||||
let version_info =
|
||||
let mut version_info =
|
||||
daedalus::minecraft::fetch_version_info(version).await?;
|
||||
|
||||
let mut new_libraries = Vec::new();
|
||||
for library in version_info.libraries {
|
||||
if let Some(patch) = patches.iter().find(|x| x.match_.contains(&library.name)) {
|
||||
if let Some(additional_libraries) = &patch.additional_libraries {
|
||||
new_libraries.push(library);
|
||||
for additional_library in additional_libraries {
|
||||
new_libraries.push(additional_library.clone());
|
||||
}
|
||||
} else if let Some(override_) = &patch.override_ {
|
||||
new_libraries.push(merge_partial_library(override_.clone(), library));
|
||||
} else {
|
||||
new_libraries.push(library);
|
||||
}
|
||||
} else {
|
||||
new_libraries.push(library);
|
||||
}
|
||||
}
|
||||
version_info.libraries = new_libraries;
|
||||
|
||||
let version_info_hash = get_hash(bytes::Bytes::from(serde_json::to_vec(&version_info)?)).await?;
|
||||
|
||||
let version_path = format!(
|
||||
"minecraft/v{}/versions/{}.json",
|
||||
daedalus::minecraft::CURRENT_FORMAT_VERSION,
|
||||
@@ -85,6 +112,7 @@ pub async fn retrieve_data(
|
||||
Some(version_info.asset_index.sha1.clone());
|
||||
cloned_manifest.versions[position].assets_index_url =
|
||||
Some(format_url(&assets_path));
|
||||
cloned_manifest.versions[position].sha1 = version_info_hash;
|
||||
}
|
||||
|
||||
let mut download_assets = false;
|
||||
@@ -187,3 +215,32 @@ pub async fn retrieve_data(
|
||||
.map_err(|_| Error::ArcError)?
|
||||
.into_inner())
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
/// A version of the fabric loader
|
||||
struct LibraryPatch {
|
||||
#[serde(rename = "_comment")]
|
||||
pub _comment: String,
|
||||
#[serde(rename = "match")]
|
||||
pub match_: Vec<String>,
|
||||
pub additional_libraries: Option<Vec<Library>>,
|
||||
#[serde(rename = "override")]
|
||||
pub override_: Option<PartialLibrary>,
|
||||
pub patch_additional_libraries: Option<bool>,
|
||||
}
|
||||
|
||||
/// Fetches the list of fabric versions
|
||||
async fn fetch_library_patches(
|
||||
url: Option<&str>,
|
||||
semaphore: Arc<Semaphore>,
|
||||
) -> Result<Vec<LibraryPatch>, Error> {
|
||||
Ok(serde_json::from_slice(
|
||||
&download_file(
|
||||
url.unwrap_or(&format_url("library-patches.json")),
|
||||
None,
|
||||
semaphore,
|
||||
)
|
||||
.await?,
|
||||
)?)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user