Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto doing fixes #8

Merged
merged 1 commit into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion daedalus/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "daedalus"
version = "0.1.21"
version = "0.1.22"
authors = ["Jai A <jaiagr+gpg@pm.me>"]
edition = "2018"
license = "MIT"
Expand Down
4 changes: 3 additions & 1 deletion daedalus/src/minecraft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,9 @@ pub fn merge_partial_library(
merge_downloads.artifact = Some(artifact);
}
if let Some(classifiers) = downloads.classifiers {
if let Some(merge_classifiers) = &mut merge_downloads.classifiers {
if let Some(merge_classifiers) =
&mut merge_downloads.classifiers
{
for classifier in classifiers {
merge_classifiers.insert(classifier.0, classifier.1);
}
Expand Down
4 changes: 2 additions & 2 deletions daedalus_client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "daedalus_client"
version = "0.1.21"
version = "0.1.22"
authors = ["Jai A <jaiagr+gpg@pm.me>"]
edition = "2018"

Expand All @@ -22,4 +22,4 @@ zip = "0.6.3"
semver = "1.0"
chrono = { version = "0.4", features = ["serde"] }
bytes = "1.3.0"
rust-s3 = "0.32.3"
rust-s3 = "0.33.0"
41 changes: 23 additions & 18 deletions daedalus_client/src/minecraft.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use crate::download_file;
use crate::{format_url, upload_file_to_bucket, Error};
use daedalus::get_hash;
use daedalus::minecraft::{merge_partial_library, Library, PartialLibrary, VersionManifest, VersionInfo};
use daedalus::minecraft::{
merge_partial_library, Library, PartialLibrary,
VersionManifest,
};
use log::info;
use serde::Deserialize;
use std::sync::Arc;
Expand All @@ -25,7 +28,7 @@ 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 patches = fetch_library_patches()?;
let cloned_patches = Arc::new(&patches);

let visited_assets_mutex = Arc::new(Mutex::new(Vec::new()));
Expand All @@ -43,10 +46,8 @@ pub async fn retrieve_data(
None
};

if let Some(old_version) = old_version {
if old_version.sha1 == version.sha1 {
return Ok(());
}
if old_version.is_some() {
return Ok(());
}

let visited_assets_mutex = Arc::clone(&visited_assets_mutex);
Expand All @@ -64,19 +65,19 @@ pub async fn retrieve_data(
let mut version_info =
daedalus::minecraft::fetch_version_info(version).await?;

fn patch_library(patches: &Vec<LibraryPatch>, mut library: Library, version_info: &VersionInfo) -> Vec<Library> {
fn patch_library(
patches: &Vec<LibraryPatch>,
mut library: Library,
) -> Vec<Library> {
let mut val = Vec::new();

let actual_patches = patches
.iter()
.filter(|x| x.match_.contains(&library.name))
.collect::<Vec<_>>();

if !actual_patches.is_empty()
{
if !actual_patches.is_empty() {
for patch in actual_patches {
println!("{} {}", version_info.id, patch._comment);

if let Some(override_) = &patch.override_ {
library = merge_partial_library(
override_.clone(),
Expand All @@ -88,8 +89,14 @@ pub async fn retrieve_data(
&patch.additional_libraries
{
for additional_library in additional_libraries {
if patch.patch_additional_libraries.unwrap_or(false) {
let mut libs = patch_library(patches, additional_library.clone(), &version_info);
if patch
.patch_additional_libraries
.unwrap_or(false)
{
let mut libs = patch_library(
patches,
additional_library.clone(),
);
val.append(&mut libs)
} else {
val.push(additional_library.clone());
Expand All @@ -108,7 +115,8 @@ pub async fn retrieve_data(

let mut new_libraries = Vec::new();
for library in version_info.libraries.clone() {
let mut libs = patch_library(&patches, library, &version_info);
let mut libs =
patch_library(&patches, library);
new_libraries.append(&mut libs)
}
version_info.libraries = new_libraries;
Expand Down Expand Up @@ -264,10 +272,7 @@ struct LibraryPatch {
}

/// Fetches the list of fabric versions
async fn fetch_library_patches(
url: Option<&str>,
semaphore: Arc<Semaphore>,
) -> Result<Vec<LibraryPatch>, Error> {
fn fetch_library_patches() -> Result<Vec<LibraryPatch>, Error> {
let patches = include_bytes!("../library-patches.json");
Ok(serde_json::from_slice(patches)?)
}