Zip extraction
This commit is contained in:
Generated
+1
@@ -3899,6 +3899,7 @@ name = "saturn-launcher"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"directories",
|
"directories",
|
||||||
|
"futures",
|
||||||
"lyceris",
|
"lyceris",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"rayon",
|
"rayon",
|
||||||
|
|||||||
@@ -27,3 +27,4 @@ once_cell = "1.21"
|
|||||||
lyceris = "1.1.3"
|
lyceris = "1.1.3"
|
||||||
rayon = "1.10.0"
|
rayon = "1.10.0"
|
||||||
reqwest = "0.12.9"
|
reqwest = "0.12.9"
|
||||||
|
futures = "0.3"
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use futures::stream::FuturesUnordered;
|
||||||
/// This module handles the installation of Minecraft, including downloading
|
/// This module handles the installation of Minecraft, including downloading
|
||||||
/// necessary files and managing the Java runtime environment.
|
/// necessary files and managing the Java runtime environment.
|
||||||
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
|
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
|
||||||
@@ -128,12 +129,31 @@ pub async fn install<T: Loader>(
|
|||||||
|
|
||||||
if !to_be_extracted.is_empty() {
|
if !to_be_extracted.is_empty() {
|
||||||
create_dir_all(&natives_path)?;
|
create_dir_all(&natives_path)?;
|
||||||
|
|
||||||
|
let tasks = FuturesUnordered::new();
|
||||||
|
|
||||||
for extract in to_be_extracted {
|
for extract in to_be_extracted {
|
||||||
if let Some(path) = extract.path {
|
let emitter = emitter.cloned();
|
||||||
let path = PathBuf::from(path);
|
let client = config.client.clone();
|
||||||
download(&extract.url, &path, emitter, config.client.as_ref()).await?;
|
let natives_path = natives_path.clone();
|
||||||
extract_file(&path, &natives_path)?;
|
|
||||||
}
|
tasks.push(tauri::async_runtime::spawn(async move {
|
||||||
|
if let Some(path) = extract.path {
|
||||||
|
let path = PathBuf::from(path);
|
||||||
|
|
||||||
|
download(&extract.url, &path, emitter.as_ref(), client.as_ref()).await?;
|
||||||
|
extract_file(&path, &natives_path)?;
|
||||||
|
|
||||||
|
Ok::<_, Error>(())
|
||||||
|
} else {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
for task in tasks {
|
||||||
|
task.await
|
||||||
|
.map_err(|e| lyceris::Error::Fail(e.to_string()))??;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -516,9 +536,7 @@ async fn download_necessary(
|
|||||||
if file.url.is_empty() {
|
if file.url.is_empty() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
if !file.path.exists()
|
if !file.path.exists() {
|
||||||
|| (!file.sha1.is_empty() && calculate_sha1(&file.path).ok()? != file.sha1)
|
|
||||||
{
|
|
||||||
return Some((file.url.clone(), file.path.clone(), file.r#type.clone()));
|
return Some((file.url.clone(), file.path.clone(), file.r#type.clone()));
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
|
|||||||
Reference in New Issue
Block a user