You've already forked AstralRinth
forked from didirus/AstralRinth
Folder names (#318)
This commit is contained in:
@@ -4,7 +4,7 @@ use crate::event::emit::{
|
||||
};
|
||||
use crate::event::LoadingBarType;
|
||||
use crate::pack::install_from::{EnvType, PackFile, PackFileHash};
|
||||
use crate::state::{LinkedData, ProfileInstallStage, SideType};
|
||||
use crate::state::{LinkedData, ProfileInstallStage, ProfilePathId, SideType};
|
||||
use crate::util::fetch::{fetch_mirrors, write};
|
||||
use crate::State;
|
||||
use async_zip::tokio::read::seek::ZipFileReader;
|
||||
@@ -20,8 +20,8 @@ use super::install_from::{
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn install_pack(
|
||||
location: CreatePackLocation,
|
||||
profile: PathBuf,
|
||||
) -> crate::Result<PathBuf> {
|
||||
profile_path: ProfilePathId,
|
||||
) -> crate::Result<ProfilePathId> {
|
||||
// Get file from description
|
||||
let description: CreatePackDescription = match location {
|
||||
CreatePackLocation::FromVersionId {
|
||||
@@ -31,12 +31,16 @@ pub async fn install_pack(
|
||||
icon_url,
|
||||
} => {
|
||||
generate_pack_from_version_id(
|
||||
project_id, version_id, title, icon_url, profile,
|
||||
project_id,
|
||||
version_id,
|
||||
title,
|
||||
icon_url,
|
||||
profile_path,
|
||||
)
|
||||
.await?
|
||||
}
|
||||
CreatePackLocation::FromFile { path } => {
|
||||
generate_pack_from_file(path, profile).await?
|
||||
generate_pack_from_file(path, profile_path).await?
|
||||
}
|
||||
};
|
||||
|
||||
@@ -46,7 +50,7 @@ pub async fn install_pack(
|
||||
let project_id = description.project_id;
|
||||
let version_id = description.version_id;
|
||||
let existing_loading_bar = description.existing_loading_bar;
|
||||
let profile = description.profile;
|
||||
let profile_path = description.profile_path;
|
||||
|
||||
let state = &State::get().await?;
|
||||
|
||||
@@ -125,7 +129,7 @@ pub async fn install_pack(
|
||||
loader_version.cloned(),
|
||||
)
|
||||
.await?;
|
||||
crate::api::profile::edit(&profile, |prof| {
|
||||
crate::api::profile::edit(&profile_path, |prof| {
|
||||
prof.metadata.name =
|
||||
override_title.clone().unwrap_or_else(|| pack.name.clone());
|
||||
prof.install_stage = ProfileInstallStage::PackInstalling;
|
||||
@@ -142,12 +146,15 @@ pub async fn install_pack(
|
||||
})
|
||||
.await?;
|
||||
|
||||
let profile = profile.clone();
|
||||
let profile_path = profile_path.clone();
|
||||
let result = async {
|
||||
let loading_bar = init_or_edit_loading(
|
||||
existing_loading_bar,
|
||||
LoadingBarType::PackDownload {
|
||||
profile_path: profile.clone(),
|
||||
profile_path: profile_path
|
||||
.get_full_path()
|
||||
.await?
|
||||
.clone(),
|
||||
pack_name: pack.name.clone(),
|
||||
icon,
|
||||
pack_id: project_id,
|
||||
@@ -169,7 +176,7 @@ pub async fn install_pack(
|
||||
num_files,
|
||||
None,
|
||||
|project| {
|
||||
let profile = profile.clone();
|
||||
let profile_path = profile_path.clone();
|
||||
async move {
|
||||
//TODO: Future update: prompt user for optional files in a modpack
|
||||
if let Some(env) = project.env {
|
||||
@@ -203,7 +210,10 @@ pub async fn install_pack(
|
||||
match path {
|
||||
Component::CurDir
|
||||
| Component::Normal(_) => {
|
||||
let path = profile.join(project.path);
|
||||
let path = profile_path
|
||||
.get_full_path()
|
||||
.await?
|
||||
.join(project.path);
|
||||
write(
|
||||
&path,
|
||||
&file,
|
||||
@@ -265,7 +275,10 @@ pub async fn install_pack(
|
||||
|
||||
if new_path.file_name().is_some() {
|
||||
write(
|
||||
&profile.join(new_path),
|
||||
&profile_path
|
||||
.get_full_path()
|
||||
.await?
|
||||
.join(new_path),
|
||||
&content,
|
||||
&state.io_semaphore,
|
||||
)
|
||||
@@ -285,7 +298,7 @@ pub async fn install_pack(
|
||||
}
|
||||
|
||||
if let Some(profile_val) =
|
||||
crate::api::profile::get(&profile, None).await?
|
||||
crate::api::profile::get(&profile_path, None).await?
|
||||
{
|
||||
crate::launcher::install_minecraft(
|
||||
&profile_val,
|
||||
@@ -296,14 +309,14 @@ pub async fn install_pack(
|
||||
State::sync().await?;
|
||||
}
|
||||
|
||||
Ok::<PathBuf, crate::Error>(profile.clone())
|
||||
Ok::<ProfilePathId, crate::Error>(profile_path.clone())
|
||||
}
|
||||
.await;
|
||||
|
||||
match result {
|
||||
Ok(profile) => Ok(profile),
|
||||
Err(err) => {
|
||||
let _ = crate::api::profile::remove(&profile).await;
|
||||
let _ = crate::api::profile::remove(&profile_path).await;
|
||||
|
||||
Err(err)
|
||||
}
|
||||
@@ -319,7 +332,7 @@ pub async fn install_pack(
|
||||
match result {
|
||||
Ok(profile) => Ok(profile),
|
||||
Err(err) => {
|
||||
let _ = crate::api::profile::remove(&profile).await;
|
||||
let _ = crate::api::profile::remove(&profile_path).await;
|
||||
|
||||
Err(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user