You've already forked AstralRinth
forked from didirus/AstralRinth
Debug pin macro (#118)
* debug pin macro * Added debug pinning macro * working on windows * removed remaining box pins
This commit is contained in:
@@ -32,6 +32,7 @@ pub async fn authenticate_await_complete_flow() -> crate::Result<Credentials> {
|
||||
/// open a browser to the given URL and finally wait on the spawned future
|
||||
/// with the ability to cancel in case the browser is closed before finishing
|
||||
#[tracing::instrument]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn authenticate(
|
||||
browser_url: oneshot::Sender<url::Url>,
|
||||
) -> crate::Result<Credentials> {
|
||||
@@ -60,6 +61,7 @@ pub async fn authenticate(
|
||||
/// Refresh some credentials using Hydra, if needed
|
||||
/// This is the primary desired way to get credentials, as it will also refresh them.
|
||||
#[tracing::instrument]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn refresh(user: uuid::Uuid) -> crate::Result<Credentials> {
|
||||
let state = State::get().await?;
|
||||
let mut users = state.users.write().await;
|
||||
|
||||
@@ -137,28 +137,27 @@ pub async fn find_java17_jres() -> crate::Result<Vec<JavaVersion>> {
|
||||
.collect())
|
||||
}
|
||||
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn auto_install_java(java_version: u32) -> crate::Result<PathBuf> {
|
||||
Box::pin(
|
||||
async move {
|
||||
let state = State::get().await?;
|
||||
let state = State::get().await?;
|
||||
|
||||
let loading_bar = init_loading(
|
||||
LoadingBarType::JavaDownload {
|
||||
version: java_version,
|
||||
},
|
||||
100.0,
|
||||
"Downloading java version",
|
||||
)
|
||||
.await?;
|
||||
let loading_bar = init_loading(
|
||||
LoadingBarType::JavaDownload {
|
||||
version: java_version,
|
||||
},
|
||||
100.0,
|
||||
"Downloading java version",
|
||||
)
|
||||
.await?;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct Package {
|
||||
pub download_url: String,
|
||||
pub name: PathBuf,
|
||||
}
|
||||
#[derive(Deserialize)]
|
||||
struct Package {
|
||||
pub download_url: String,
|
||||
pub name: PathBuf,
|
||||
}
|
||||
|
||||
emit_loading(&loading_bar, 0.0, Some("Fetching java version")).await?;
|
||||
let packages = fetch_json::<Vec<Package>>(
|
||||
emit_loading(&loading_bar, 0.0, Some("Fetching java version")).await?;
|
||||
let packages = fetch_json::<Vec<Package>>(
|
||||
Method::GET,
|
||||
&format!(
|
||||
"https://api.azul.com/metadata/v1/zulu/packages?arch={}&java_version={}&os={}&archive_type=zip&javafx_bundled=false&java_package_type=jre&page_size=1",
|
||||
@@ -168,58 +167,56 @@ pub async fn auto_install_java(java_version: u32) -> crate::Result<PathBuf> {
|
||||
None,
|
||||
&state.fetch_semaphore,
|
||||
).await?;
|
||||
emit_loading(&loading_bar, 10.0, Some("Downloading java version")).await?;
|
||||
emit_loading(&loading_bar, 10.0, Some("Downloading java version")).await?;
|
||||
|
||||
if let Some(download) = packages.first() {
|
||||
let file = fetch_advanced(
|
||||
Method::GET,
|
||||
&download.download_url,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
Some((&loading_bar, 80.0)),
|
||||
&state.fetch_semaphore,
|
||||
)
|
||||
.await?;
|
||||
if let Some(download) = packages.first() {
|
||||
let file = fetch_advanced(
|
||||
Method::GET,
|
||||
&download.download_url,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
Some((&loading_bar, 80.0)),
|
||||
&state.fetch_semaphore,
|
||||
)
|
||||
.await?;
|
||||
|
||||
let path = state.directories.java_versions_dir();
|
||||
let path = state.directories.java_versions_dir();
|
||||
|
||||
if path.exists() {
|
||||
tokio::fs::remove_dir_all(&path).await?;
|
||||
}
|
||||
if path.exists() {
|
||||
tokio::fs::remove_dir_all(&path).await?;
|
||||
}
|
||||
|
||||
let mut archive = zip::ZipArchive::new(std::io::Cursor::new(file))
|
||||
.map_err(|_| {
|
||||
crate::Error::from(crate::ErrorKind::InputError(
|
||||
"Failed to read java zip".to_string(),
|
||||
))
|
||||
})?;
|
||||
let mut archive = zip::ZipArchive::new(std::io::Cursor::new(file))
|
||||
.map_err(|_| {
|
||||
crate::Error::from(crate::ErrorKind::InputError(
|
||||
"Failed to read java zip".to_string(),
|
||||
))
|
||||
})?;
|
||||
|
||||
emit_loading(&loading_bar, 0.0, Some("Extracting java")).await?;
|
||||
archive.extract(&path).map_err(|_| {
|
||||
crate::Error::from(crate::ErrorKind::InputError(
|
||||
"Failed to extract java zip".to_string(),
|
||||
))
|
||||
})?;
|
||||
emit_loading(&loading_bar, 100.0, Some("Done extracting java")).await?;
|
||||
Ok(path
|
||||
.join(
|
||||
download
|
||||
.name
|
||||
.file_stem()
|
||||
.unwrap_or_default()
|
||||
.to_string_lossy()
|
||||
.to_string(),
|
||||
)
|
||||
.join(format!("zulu-{}.jre/Contents/Home/bin/java", java_version)))
|
||||
} else {
|
||||
Err(crate::ErrorKind::LauncherError(format!(
|
||||
emit_loading(&loading_bar, 0.0, Some("Extracting java")).await?;
|
||||
archive.extract(&path).map_err(|_| {
|
||||
crate::Error::from(crate::ErrorKind::InputError(
|
||||
"Failed to extract java zip".to_string(),
|
||||
))
|
||||
})?;
|
||||
emit_loading(&loading_bar, 100.0, Some("Done extracting java")).await?;
|
||||
Ok(path
|
||||
.join(
|
||||
download
|
||||
.name
|
||||
.file_stem()
|
||||
.unwrap_or_default()
|
||||
.to_string_lossy()
|
||||
.to_string(),
|
||||
)
|
||||
.join(format!("zulu-{}.jre/Contents/Home/bin/java", java_version)))
|
||||
} else {
|
||||
Err(crate::ErrorKind::LauncherError(format!(
|
||||
"No Java Version found for Java version {}, OS {}, and Architecture {}",
|
||||
java_version, std::env::consts::OS, std::env::consts::ARCH,
|
||||
)).into())
|
||||
}
|
||||
}
|
||||
).await
|
||||
}
|
||||
}
|
||||
|
||||
// Get all JREs that exist on the system
|
||||
|
||||
@@ -76,125 +76,124 @@ enum PackDependency {
|
||||
Minecraft,
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn install_pack_from_version_id(
|
||||
version_id: String,
|
||||
title: String,
|
||||
icon_url: Option<String>,
|
||||
) -> crate::Result<PathBuf> {
|
||||
let state = State::get().await?;
|
||||
Box::pin(async move {
|
||||
let profile = crate::api::profile_create::profile_create(
|
||||
title.clone(),
|
||||
"1.19.4".to_string(),
|
||||
ModLoader::Vanilla,
|
||||
None,
|
||||
None,
|
||||
icon_url.clone(),
|
||||
None,
|
||||
Some(true),
|
||||
)
|
||||
.await?;
|
||||
let profile = crate::api::profile_create::profile_create(
|
||||
title.clone(),
|
||||
"1.19.4".to_string(),
|
||||
ModLoader::Vanilla,
|
||||
None,
|
||||
None,
|
||||
icon_url.clone(),
|
||||
None,
|
||||
Some(true),
|
||||
)
|
||||
.await?;
|
||||
|
||||
let loading_bar = init_loading(
|
||||
LoadingBarType::PackFileDownload {
|
||||
profile_path: profile.clone(),
|
||||
pack_name: title,
|
||||
icon: icon_url,
|
||||
pack_version: version_id.clone(),
|
||||
},
|
||||
100.0,
|
||||
"Downloading pack file",
|
||||
)
|
||||
.await?;
|
||||
let loading_bar = init_loading(
|
||||
LoadingBarType::PackFileDownload {
|
||||
profile_path: profile.clone(),
|
||||
pack_name: title,
|
||||
icon: icon_url,
|
||||
pack_version: version_id.clone(),
|
||||
},
|
||||
100.0,
|
||||
"Downloading pack file",
|
||||
)
|
||||
.await?;
|
||||
|
||||
emit_loading(&loading_bar, 0.0, Some("Fetching version")).await?;
|
||||
let version: ModrinthVersion = fetch_json(
|
||||
Method::GET,
|
||||
&format!("{}version/{}", MODRINTH_API_URL, version_id),
|
||||
None,
|
||||
None,
|
||||
&state.fetch_semaphore,
|
||||
)
|
||||
.await?;
|
||||
emit_loading(&loading_bar, 10.0, None).await?;
|
||||
emit_loading(&loading_bar, 0.0, Some("Fetching version")).await?;
|
||||
let version: ModrinthVersion = fetch_json(
|
||||
Method::GET,
|
||||
&format!("{}version/{}", MODRINTH_API_URL, version_id),
|
||||
None,
|
||||
None,
|
||||
&state.fetch_semaphore,
|
||||
)
|
||||
.await?;
|
||||
emit_loading(&loading_bar, 10.0, None).await?;
|
||||
|
||||
let (url, hash) =
|
||||
if let Some(file) = version.files.iter().find(|x| x.primary) {
|
||||
Some((file.url.clone(), file.hashes.get("sha1")))
|
||||
} else {
|
||||
version
|
||||
.files
|
||||
.first()
|
||||
.map(|file| (file.url.clone(), file.hashes.get("sha1")))
|
||||
}
|
||||
.ok_or_else(|| {
|
||||
crate::ErrorKind::InputError(
|
||||
"Specified version has no files".to_string(),
|
||||
let (url, hash) =
|
||||
if let Some(file) = version.files.iter().find(|x| x.primary) {
|
||||
Some((file.url.clone(), file.hashes.get("sha1")))
|
||||
} else {
|
||||
version
|
||||
.files
|
||||
.first()
|
||||
.map(|file| (file.url.clone(), file.hashes.get("sha1")))
|
||||
}
|
||||
.ok_or_else(|| {
|
||||
crate::ErrorKind::InputError(
|
||||
"Specified version has no files".to_string(),
|
||||
)
|
||||
})?;
|
||||
|
||||
let file = fetch_advanced(
|
||||
Method::GET,
|
||||
&url,
|
||||
hash.map(|x| &**x),
|
||||
None,
|
||||
None,
|
||||
Some((&loading_bar, 70.0)),
|
||||
&state.fetch_semaphore,
|
||||
)
|
||||
.await?;
|
||||
emit_loading(&loading_bar, 0.0, Some("Fetching project metadata")).await?;
|
||||
|
||||
let project: ModrinthProject = fetch_json(
|
||||
Method::GET,
|
||||
&format!("{}project/{}", MODRINTH_API_URL, version.project_id),
|
||||
None,
|
||||
None,
|
||||
&state.fetch_semaphore,
|
||||
)
|
||||
.await?;
|
||||
|
||||
emit_loading(&loading_bar, 10.0, Some("Retrieving icon")).await?;
|
||||
let icon = if let Some(icon_url) = project.icon_url {
|
||||
let state = State::get().await?;
|
||||
let icon_bytes = fetch(&icon_url, None, &state.fetch_semaphore).await?;
|
||||
|
||||
let filename = icon_url.rsplit('/').next();
|
||||
|
||||
if let Some(filename) = filename {
|
||||
Some(
|
||||
write_cached_icon(
|
||||
filename,
|
||||
&state.directories.caches_dir(),
|
||||
icon_bytes,
|
||||
&state.io_semaphore,
|
||||
)
|
||||
})?;
|
||||
|
||||
let file = fetch_advanced(
|
||||
Method::GET,
|
||||
&url,
|
||||
hash.map(|x| &**x),
|
||||
None,
|
||||
None,
|
||||
Some((&loading_bar, 70.0)),
|
||||
&state.fetch_semaphore,
|
||||
)
|
||||
.await?;
|
||||
emit_loading(&loading_bar, 0.0, Some("Fetching project metadata"))
|
||||
.await?;
|
||||
|
||||
let project: ModrinthProject = fetch_json(
|
||||
Method::GET,
|
||||
&format!("{}project/{}", MODRINTH_API_URL, version.project_id),
|
||||
None,
|
||||
None,
|
||||
&state.fetch_semaphore,
|
||||
)
|
||||
.await?;
|
||||
|
||||
emit_loading(&loading_bar, 10.0, Some("Retrieving icon")).await?;
|
||||
let icon = if let Some(icon_url) = project.icon_url {
|
||||
let state = State::get().await?;
|
||||
let icon_bytes =
|
||||
fetch(&icon_url, None, &state.fetch_semaphore).await?;
|
||||
|
||||
let filename = icon_url.rsplit('/').next();
|
||||
|
||||
if let Some(filename) = filename {
|
||||
Some(
|
||||
write_cached_icon(
|
||||
filename,
|
||||
&state.directories.caches_dir(),
|
||||
icon_bytes,
|
||||
&state.io_semaphore,
|
||||
)
|
||||
.await?,
|
||||
)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
.await?,
|
||||
)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
emit_loading(&loading_bar, 10.0, None).await?;
|
||||
}
|
||||
} else {
|
||||
None
|
||||
};
|
||||
emit_loading(&loading_bar, 10.0, None).await?;
|
||||
|
||||
install_pack(
|
||||
file,
|
||||
icon,
|
||||
Some(project.title),
|
||||
Some(version.project_id),
|
||||
Some(version.id),
|
||||
Some(loading_bar),
|
||||
profile,
|
||||
)
|
||||
.await
|
||||
})
|
||||
install_pack(
|
||||
file,
|
||||
icon,
|
||||
Some(project.title),
|
||||
Some(version.project_id),
|
||||
Some(version.id),
|
||||
Some(loading_bar),
|
||||
profile,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn install_pack_from_file(path: PathBuf) -> crate::Result<PathBuf> {
|
||||
let file = fs::read(&path).await?;
|
||||
|
||||
@@ -228,6 +227,8 @@ pub async fn install_pack_from_file(path: PathBuf) -> crate::Result<PathBuf> {
|
||||
.await
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
#[theseus_macros::debug_pin]
|
||||
async fn install_pack(
|
||||
file: bytes::Bytes,
|
||||
icon: Option<PathBuf>,
|
||||
@@ -239,270 +240,261 @@ async fn install_pack(
|
||||
) -> crate::Result<PathBuf> {
|
||||
let state = &State::get().await?;
|
||||
|
||||
Box::pin(async move {
|
||||
let reader: Cursor<&bytes::Bytes> = Cursor::new(&file);
|
||||
let reader: Cursor<&bytes::Bytes> = Cursor::new(&file);
|
||||
|
||||
// Create zip reader around file
|
||||
let mut zip_reader =
|
||||
ZipFileReader::new(reader).await.map_err(|_| {
|
||||
crate::Error::from(crate::ErrorKind::InputError(
|
||||
"Failed to read input modpack zip".to_string(),
|
||||
))
|
||||
})?;
|
||||
// Create zip reader around file
|
||||
let mut zip_reader = ZipFileReader::new(reader).await.map_err(|_| {
|
||||
crate::Error::from(crate::ErrorKind::InputError(
|
||||
"Failed to read input modpack zip".to_string(),
|
||||
))
|
||||
})?;
|
||||
|
||||
// Extract index of modrinth.index.json
|
||||
let zip_index_option = zip_reader
|
||||
// Extract index of modrinth.index.json
|
||||
let zip_index_option = zip_reader
|
||||
.file()
|
||||
.entries()
|
||||
.iter()
|
||||
.position(|f| f.entry().filename() == "modrinth.index.json");
|
||||
if let Some(zip_index) = zip_index_option {
|
||||
let mut manifest = String::new();
|
||||
let entry = zip_reader
|
||||
.file()
|
||||
.entries()
|
||||
.iter()
|
||||
.position(|f| f.entry().filename() == "modrinth.index.json");
|
||||
if let Some(zip_index) = zip_index_option {
|
||||
let mut manifest = String::new();
|
||||
let entry = zip_reader
|
||||
.file()
|
||||
.entries()
|
||||
.get(zip_index)
|
||||
.unwrap()
|
||||
.entry()
|
||||
.clone();
|
||||
let mut reader = zip_reader.entry(zip_index).await?;
|
||||
reader.read_to_string_checked(&mut manifest, &entry).await?;
|
||||
.get(zip_index)
|
||||
.unwrap()
|
||||
.entry()
|
||||
.clone();
|
||||
let mut reader = zip_reader.entry(zip_index).await?;
|
||||
reader.read_to_string_checked(&mut manifest, &entry).await?;
|
||||
|
||||
let pack: PackFormat = serde_json::from_str(&manifest)?;
|
||||
let pack: PackFormat = serde_json::from_str(&manifest)?;
|
||||
|
||||
if &*pack.game != "minecraft" {
|
||||
return Err(crate::ErrorKind::InputError(
|
||||
"Pack does not support Minecraft".to_string(),
|
||||
)
|
||||
.into());
|
||||
}
|
||||
if &*pack.game != "minecraft" {
|
||||
return Err(crate::ErrorKind::InputError(
|
||||
"Pack does not support Minecraft".to_string(),
|
||||
)
|
||||
.into());
|
||||
}
|
||||
|
||||
let mut game_version = None;
|
||||
let mut mod_loader = None;
|
||||
let mut loader_version = None;
|
||||
for (key, value) in &pack.dependencies {
|
||||
match key {
|
||||
PackDependency::Forge => {
|
||||
mod_loader = Some(ModLoader::Forge);
|
||||
loader_version = Some(value);
|
||||
}
|
||||
PackDependency::FabricLoader => {
|
||||
mod_loader = Some(ModLoader::Fabric);
|
||||
loader_version = Some(value);
|
||||
}
|
||||
PackDependency::QuiltLoader => {
|
||||
mod_loader = Some(ModLoader::Quilt);
|
||||
loader_version = Some(value);
|
||||
}
|
||||
PackDependency::Minecraft => game_version = Some(value),
|
||||
let mut game_version = None;
|
||||
let mut mod_loader = None;
|
||||
let mut loader_version = None;
|
||||
for (key, value) in &pack.dependencies {
|
||||
match key {
|
||||
PackDependency::Forge => {
|
||||
mod_loader = Some(ModLoader::Forge);
|
||||
loader_version = Some(value);
|
||||
}
|
||||
PackDependency::FabricLoader => {
|
||||
mod_loader = Some(ModLoader::Fabric);
|
||||
loader_version = Some(value);
|
||||
}
|
||||
PackDependency::QuiltLoader => {
|
||||
mod_loader = Some(ModLoader::Quilt);
|
||||
loader_version = Some(value);
|
||||
}
|
||||
PackDependency::Minecraft => game_version = Some(value),
|
||||
}
|
||||
}
|
||||
|
||||
let game_version = if let Some(game_version) = game_version {
|
||||
game_version
|
||||
} else {
|
||||
return Err(crate::ErrorKind::InputError(
|
||||
"Pack did not specify Minecraft version".to_string(),
|
||||
)
|
||||
.into());
|
||||
};
|
||||
let game_version = if let Some(game_version) = game_version {
|
||||
game_version
|
||||
} else {
|
||||
return Err(crate::ErrorKind::InputError(
|
||||
"Pack did not specify Minecraft version".to_string(),
|
||||
)
|
||||
.into());
|
||||
};
|
||||
|
||||
let loader_version =
|
||||
crate::profile_create::get_loader_version_from_loader(
|
||||
game_version.clone(),
|
||||
mod_loader.unwrap_or(ModLoader::Vanilla),
|
||||
loader_version.cloned(),
|
||||
)
|
||||
.await?;
|
||||
crate::api::profile::edit(&profile, |prof| {
|
||||
prof.metadata.name =
|
||||
override_title.clone().unwrap_or_else(|| pack.name.clone());
|
||||
prof.install_stage = ProfileInstallStage::PackInstalling;
|
||||
prof.metadata.linked_data = Some(LinkedData {
|
||||
project_id: project_id.clone(),
|
||||
version_id: version_id.clone(),
|
||||
});
|
||||
prof.metadata.icon = icon.clone();
|
||||
prof.metadata.game_version = game_version.clone();
|
||||
prof.metadata.loader_version = loader_version.clone();
|
||||
prof.metadata.loader = mod_loader.unwrap_or(ModLoader::Vanilla);
|
||||
|
||||
async { Ok(()) }
|
||||
})
|
||||
let loader_version =
|
||||
crate::profile_create::get_loader_version_from_loader(
|
||||
game_version.clone(),
|
||||
mod_loader.unwrap_or(ModLoader::Vanilla),
|
||||
loader_version.cloned(),
|
||||
)
|
||||
.await?;
|
||||
State::sync().await?;
|
||||
crate::api::profile::edit(&profile, |prof| {
|
||||
prof.metadata.name =
|
||||
override_title.clone().unwrap_or_else(|| pack.name.clone());
|
||||
prof.install_stage = ProfileInstallStage::PackInstalling;
|
||||
prof.metadata.linked_data = Some(LinkedData {
|
||||
project_id: project_id.clone(),
|
||||
version_id: version_id.clone(),
|
||||
});
|
||||
prof.metadata.icon = icon.clone();
|
||||
prof.metadata.game_version = game_version.clone();
|
||||
prof.metadata.loader_version = loader_version.clone();
|
||||
prof.metadata.loader = mod_loader.unwrap_or(ModLoader::Vanilla);
|
||||
|
||||
let profile = profile.clone();
|
||||
let result = async {
|
||||
let loading_bar = init_or_edit_loading(
|
||||
existing_loading_bar,
|
||||
LoadingBarType::PackDownload {
|
||||
profile_path: profile.clone(),
|
||||
pack_name: pack.name.clone(),
|
||||
icon,
|
||||
pack_id: project_id,
|
||||
pack_version: version_id,
|
||||
},
|
||||
100.0,
|
||||
"Downloading modpack",
|
||||
)
|
||||
.await?;
|
||||
async { Ok(()) }
|
||||
})
|
||||
.await?;
|
||||
State::sync().await?;
|
||||
|
||||
let num_files = pack.files.len();
|
||||
use futures::StreamExt;
|
||||
loading_try_for_each_concurrent(
|
||||
futures::stream::iter(pack.files.into_iter())
|
||||
.map(Ok::<PackFile, crate::Error>),
|
||||
None,
|
||||
Some(&loading_bar),
|
||||
70.0,
|
||||
num_files,
|
||||
None,
|
||||
|project| {
|
||||
let profile = profile.clone();
|
||||
async move {
|
||||
//TODO: Future update: prompt user for optional files in a modpack
|
||||
if let Some(env) = project.env {
|
||||
if env
|
||||
.get(&EnvType::Client)
|
||||
.map(|x| x == &SideType::Unsupported)
|
||||
.unwrap_or(false)
|
||||
{
|
||||
return Ok(());
|
||||
}
|
||||
let profile = profile.clone();
|
||||
let result = async {
|
||||
let loading_bar = init_or_edit_loading(
|
||||
existing_loading_bar,
|
||||
LoadingBarType::PackDownload {
|
||||
profile_path: profile.clone(),
|
||||
pack_name: pack.name.clone(),
|
||||
icon,
|
||||
pack_id: project_id,
|
||||
pack_version: version_id,
|
||||
},
|
||||
100.0,
|
||||
"Downloading modpack",
|
||||
)
|
||||
.await?;
|
||||
|
||||
let num_files = pack.files.len();
|
||||
use futures::StreamExt;
|
||||
loading_try_for_each_concurrent(
|
||||
futures::stream::iter(pack.files.into_iter())
|
||||
.map(Ok::<PackFile, crate::Error>),
|
||||
None,
|
||||
Some(&loading_bar),
|
||||
70.0,
|
||||
num_files,
|
||||
None,
|
||||
|project| {
|
||||
let profile = profile.clone();
|
||||
async move {
|
||||
//TODO: Future update: prompt user for optional files in a modpack
|
||||
if let Some(env) = project.env {
|
||||
if env
|
||||
.get(&EnvType::Client)
|
||||
.map(|x| x == &SideType::Unsupported)
|
||||
.unwrap_or(false)
|
||||
{
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
let file = fetch_mirrors(
|
||||
&project
|
||||
.downloads
|
||||
.iter()
|
||||
.map(|x| &**x)
|
||||
.collect::<Vec<&str>>(),
|
||||
project
|
||||
.hashes
|
||||
.get(&PackFileHash::Sha1)
|
||||
.map(|x| &**x),
|
||||
&state.fetch_semaphore,
|
||||
)
|
||||
.await?;
|
||||
let file = fetch_mirrors(
|
||||
&project
|
||||
.downloads
|
||||
.iter()
|
||||
.map(|x| &**x)
|
||||
.collect::<Vec<&str>>(),
|
||||
project
|
||||
.hashes
|
||||
.get(&PackFileHash::Sha1)
|
||||
.map(|x| &**x),
|
||||
&state.fetch_semaphore,
|
||||
)
|
||||
.await?;
|
||||
|
||||
let path = std::path::Path::new(&project.path)
|
||||
.components()
|
||||
.next();
|
||||
if let Some(path) = path {
|
||||
match path {
|
||||
Component::CurDir
|
||||
| Component::Normal(_) => {
|
||||
let path = profile.join(project.path);
|
||||
write(
|
||||
&path,
|
||||
&file,
|
||||
&state.io_semaphore,
|
||||
)
|
||||
let path = std::path::Path::new(&project.path)
|
||||
.components()
|
||||
.next();
|
||||
if let Some(path) = path {
|
||||
match path {
|
||||
Component::CurDir | Component::Normal(_) => {
|
||||
let path = profile.join(project.path);
|
||||
write(&path, &file, &state.io_semaphore)
|
||||
.await?;
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
},
|
||||
)
|
||||
Ok(())
|
||||
}
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
|
||||
emit_loading(&loading_bar, 0.0, Some("Extracting overrides"))
|
||||
.await?;
|
||||
|
||||
emit_loading(&loading_bar, 0.0, Some("Extracting overrides"))
|
||||
.await?;
|
||||
let mut total_len = 0;
|
||||
|
||||
let mut total_len = 0;
|
||||
for index in 0..zip_reader.file().entries().len() {
|
||||
let file =
|
||||
zip_reader.file().entries().get(index).unwrap().entry();
|
||||
|
||||
for index in 0..zip_reader.file().entries().len() {
|
||||
let file =
|
||||
zip_reader.file().entries().get(index).unwrap().entry();
|
||||
|
||||
if (file.filename().starts_with("overrides")
|
||||
|| file.filename().starts_with("client_overrides"))
|
||||
&& !file.filename().ends_with('/')
|
||||
{
|
||||
total_len += 1;
|
||||
}
|
||||
if (file.filename().starts_with("overrides")
|
||||
|| file.filename().starts_with("client_overrides"))
|
||||
&& !file.filename().ends_with('/')
|
||||
{
|
||||
total_len += 1;
|
||||
}
|
||||
}
|
||||
|
||||
for index in 0..zip_reader.file().entries().len() {
|
||||
let file = zip_reader
|
||||
.file()
|
||||
.entries()
|
||||
.get(index)
|
||||
.unwrap()
|
||||
.entry()
|
||||
.clone();
|
||||
for index in 0..zip_reader.file().entries().len() {
|
||||
let file = zip_reader
|
||||
.file()
|
||||
.entries()
|
||||
.get(index)
|
||||
.unwrap()
|
||||
.entry()
|
||||
.clone();
|
||||
|
||||
let file_path = PathBuf::from(file.filename());
|
||||
if (file.filename().starts_with("overrides")
|
||||
|| file.filename().starts_with("client_overrides"))
|
||||
&& !file.filename().ends_with('/')
|
||||
{
|
||||
// Reads the file into the 'content' variable
|
||||
let mut content = Vec::new();
|
||||
let mut reader = zip_reader.entry(index).await?;
|
||||
reader.read_to_end_checked(&mut content, &file).await?;
|
||||
let file_path = PathBuf::from(file.filename());
|
||||
if (file.filename().starts_with("overrides")
|
||||
|| file.filename().starts_with("client_overrides"))
|
||||
&& !file.filename().ends_with('/')
|
||||
{
|
||||
// Reads the file into the 'content' variable
|
||||
let mut content = Vec::new();
|
||||
let mut reader = zip_reader.entry(index).await?;
|
||||
reader.read_to_end_checked(&mut content, &file).await?;
|
||||
|
||||
let mut new_path = PathBuf::new();
|
||||
let components = file_path.components().skip(1);
|
||||
let mut new_path = PathBuf::new();
|
||||
let components = file_path.components().skip(1);
|
||||
|
||||
for component in components {
|
||||
new_path.push(component);
|
||||
}
|
||||
for component in components {
|
||||
new_path.push(component);
|
||||
}
|
||||
|
||||
if new_path.file_name().is_some() {
|
||||
write(
|
||||
&profile.join(new_path),
|
||||
&content,
|
||||
&state.io_semaphore,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
emit_loading(
|
||||
&loading_bar,
|
||||
30.0 / total_len as f64,
|
||||
Some(&format!(
|
||||
"Extracting override {}/{}",
|
||||
index, total_len
|
||||
)),
|
||||
if new_path.file_name().is_some() {
|
||||
write(
|
||||
&profile.join(new_path),
|
||||
&content,
|
||||
&state.io_semaphore,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(profile_val) =
|
||||
crate::api::profile::get(&profile, None).await?
|
||||
{
|
||||
crate::launcher::install_minecraft(
|
||||
&profile_val,
|
||||
Some(loading_bar),
|
||||
emit_loading(
|
||||
&loading_bar,
|
||||
30.0 / total_len as f64,
|
||||
Some(&format!(
|
||||
"Extracting override {}/{}",
|
||||
index, total_len
|
||||
)),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
Ok::<PathBuf, crate::Error>(profile.clone())
|
||||
}
|
||||
.await;
|
||||
|
||||
match result {
|
||||
Ok(profile) => Ok(profile),
|
||||
Err(err) => {
|
||||
let _ = crate::api::profile::remove(&profile).await;
|
||||
|
||||
Err(err)
|
||||
}
|
||||
if let Some(profile_val) =
|
||||
crate::api::profile::get(&profile, None).await?
|
||||
{
|
||||
crate::launcher::install_minecraft(
|
||||
&profile_val,
|
||||
Some(loading_bar),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
} else {
|
||||
let _ = crate::api::profile::remove(&profile).await;
|
||||
|
||||
Err(crate::Error::from(crate::ErrorKind::InputError(
|
||||
"No pack manifest found in mrpack".to_string(),
|
||||
)))
|
||||
Ok::<PathBuf, crate::Error>(profile.clone())
|
||||
}
|
||||
})
|
||||
.await
|
||||
.await;
|
||||
|
||||
match result {
|
||||
Ok(profile) => Ok(profile),
|
||||
Err(err) => {
|
||||
let _ = crate::api::profile::remove(&profile).await;
|
||||
|
||||
Err(err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let _ = crate::api::profile::remove(&profile).await;
|
||||
|
||||
Err(crate::Error::from(crate::ErrorKind::InputError(
|
||||
"No pack manifest found in mrpack".to_string(),
|
||||
)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,47 +123,48 @@ pub async fn install(path: &Path) -> crate::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn update_all(profile_path: &Path) -> crate::Result<()> {
|
||||
Box::pin(async move {
|
||||
if let Some(profile) = get(profile_path, None).await? {
|
||||
let loading_bar = init_loading(
|
||||
LoadingBarType::ProfileUpdate {
|
||||
profile_path: profile.path.clone(),
|
||||
profile_name: profile.metadata.name.clone(),
|
||||
},
|
||||
100.0,
|
||||
"Updating profile",
|
||||
)
|
||||
.await?;
|
||||
if let Some(profile) = get(profile_path, None).await? {
|
||||
let loading_bar = init_loading(
|
||||
LoadingBarType::ProfileUpdate {
|
||||
profile_path: profile.path.clone(),
|
||||
profile_name: profile.metadata.name.clone(),
|
||||
},
|
||||
100.0,
|
||||
"Updating profile",
|
||||
)
|
||||
.await?;
|
||||
|
||||
use futures::StreamExt;
|
||||
loading_try_for_each_concurrent(
|
||||
futures::stream::iter(profile.projects.keys())
|
||||
.map(Ok::<&PathBuf, crate::Error>),
|
||||
None,
|
||||
Some(&loading_bar),
|
||||
100.0,
|
||||
profile.projects.keys().len(),
|
||||
None,
|
||||
|project| async move {
|
||||
let _ = update_project(profile_path, project).await?;
|
||||
use futures::StreamExt;
|
||||
loading_try_for_each_concurrent(
|
||||
futures::stream::iter(profile.projects.keys())
|
||||
.map(Ok::<&PathBuf, crate::Error>),
|
||||
None,
|
||||
Some(&loading_bar),
|
||||
100.0,
|
||||
profile.projects.keys().len(),
|
||||
None,
|
||||
|project| async move {
|
||||
let _ = update_project(profile_path, project).await?;
|
||||
|
||||
Ok(())
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
Ok(())
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
} else {
|
||||
Err(crate::ErrorKind::UnmanagedProfileError(
|
||||
profile_path.display().to_string(),
|
||||
)
|
||||
.as_error())
|
||||
}
|
||||
})
|
||||
.await
|
||||
Ok(())
|
||||
} else {
|
||||
Err(crate::ErrorKind::UnmanagedProfileError(
|
||||
profile_path.display().to_string(),
|
||||
)
|
||||
.as_error())
|
||||
}
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn update_project(
|
||||
profile_path: &Path,
|
||||
project_path: &Path,
|
||||
@@ -304,113 +305,108 @@ pub async fn remove_project(
|
||||
/// failing with an error if no credentials are available
|
||||
#[tracing::instrument]
|
||||
pub async fn run(path: &Path) -> crate::Result<Arc<RwLock<MinecraftChild>>> {
|
||||
Box::pin(async move {
|
||||
let state = State::get().await?;
|
||||
let state = State::get().await?;
|
||||
|
||||
// Get default account and refresh credentials (preferred way to log in)
|
||||
let default_account = state.settings.read().await.default_user;
|
||||
let credentials = if let Some(default_account) = default_account {
|
||||
refresh(default_account).await?
|
||||
// Get default account and refresh credentials (preferred way to log in)
|
||||
let default_account = state.settings.read().await.default_user;
|
||||
let credentials = if let Some(default_account) = default_account {
|
||||
refresh(default_account).await?
|
||||
} else {
|
||||
// If no default account, try to use a logged in account
|
||||
let users = auth::users().await?;
|
||||
let last_account = users.first();
|
||||
if let Some(last_account) = last_account {
|
||||
refresh(last_account.id).await?
|
||||
} else {
|
||||
// If no default account, try to use a logged in account
|
||||
let users = auth::users().await?;
|
||||
let last_account = users.first();
|
||||
if let Some(last_account) = last_account {
|
||||
refresh(last_account.id).await?
|
||||
} else {
|
||||
return Err(crate::ErrorKind::NoCredentialsError.as_error());
|
||||
}
|
||||
};
|
||||
run_credentials(path, &credentials).await
|
||||
})
|
||||
.await
|
||||
return Err(crate::ErrorKind::NoCredentialsError.as_error());
|
||||
}
|
||||
};
|
||||
run_credentials(path, &credentials).await
|
||||
}
|
||||
|
||||
/// Run Minecraft using a profile, and credentials for authentication
|
||||
/// Returns Arc pointer to RwLock to Child
|
||||
#[tracing::instrument]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub async fn run_credentials(
|
||||
path: &Path,
|
||||
credentials: &auth::Credentials,
|
||||
) -> crate::Result<Arc<RwLock<MinecraftChild>>> {
|
||||
Box::pin(async move {
|
||||
let state = State::get().await?;
|
||||
let settings = state.settings.read().await;
|
||||
let profile = get(path, None).await?.ok_or_else(|| {
|
||||
crate::ErrorKind::OtherError(format!(
|
||||
"Tried to run a nonexistent or unloaded profile at path {}!",
|
||||
path.display()
|
||||
))
|
||||
})?;
|
||||
let state = State::get().await?;
|
||||
let settings = state.settings.read().await;
|
||||
let profile = get(path, None).await?.ok_or_else(|| {
|
||||
crate::ErrorKind::OtherError(format!(
|
||||
"Tried to run a nonexistent or unloaded profile at path {}!",
|
||||
path.display()
|
||||
))
|
||||
})?;
|
||||
|
||||
let pre_launch_hooks =
|
||||
&profile.hooks.as_ref().unwrap_or(&settings.hooks).pre_launch;
|
||||
if let Some(hook) = pre_launch_hooks {
|
||||
// TODO: hook parameters
|
||||
let mut cmd = hook.split(' ');
|
||||
if let Some(command) = cmd.next() {
|
||||
let result = Command::new(command)
|
||||
.args(&cmd.collect::<Vec<&str>>())
|
||||
.current_dir(path)
|
||||
.spawn()?
|
||||
.wait()
|
||||
.await?;
|
||||
let pre_launch_hooks =
|
||||
&profile.hooks.as_ref().unwrap_or(&settings.hooks).pre_launch;
|
||||
if let Some(hook) = pre_launch_hooks {
|
||||
// TODO: hook parameters
|
||||
let mut cmd = hook.split(' ');
|
||||
if let Some(command) = cmd.next() {
|
||||
let result = Command::new(command)
|
||||
.args(&cmd.collect::<Vec<&str>>())
|
||||
.current_dir(path)
|
||||
.spawn()?
|
||||
.wait()
|
||||
.await?;
|
||||
|
||||
if !result.success() {
|
||||
return Err(crate::ErrorKind::LauncherError(format!(
|
||||
"Non-zero exit code for pre-launch hook: {}",
|
||||
result.code().unwrap_or(-1)
|
||||
))
|
||||
.as_error());
|
||||
}
|
||||
if !result.success() {
|
||||
return Err(crate::ErrorKind::LauncherError(format!(
|
||||
"Non-zero exit code for pre-launch hook: {}",
|
||||
result.code().unwrap_or(-1)
|
||||
))
|
||||
.as_error());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let java_args = profile
|
||||
.java
|
||||
.as_ref()
|
||||
.and_then(|it| it.extra_arguments.as_ref())
|
||||
.unwrap_or(&settings.custom_java_args);
|
||||
let java_args = profile
|
||||
.java
|
||||
.as_ref()
|
||||
.and_then(|it| it.extra_arguments.as_ref())
|
||||
.unwrap_or(&settings.custom_java_args);
|
||||
|
||||
let wrapper = profile
|
||||
.hooks
|
||||
.as_ref()
|
||||
.map_or(&settings.hooks.wrapper, |it| &it.wrapper);
|
||||
let wrapper = profile
|
||||
.hooks
|
||||
.as_ref()
|
||||
.map_or(&settings.hooks.wrapper, |it| &it.wrapper);
|
||||
|
||||
let memory = profile.memory.unwrap_or(settings.memory);
|
||||
let resolution = profile.resolution.unwrap_or(settings.game_resolution);
|
||||
let memory = profile.memory.unwrap_or(settings.memory);
|
||||
let resolution = profile.resolution.unwrap_or(settings.game_resolution);
|
||||
|
||||
let env_args = &settings.custom_env_args;
|
||||
let env_args = &settings.custom_env_args;
|
||||
|
||||
// Post post exit hooks
|
||||
let post_exit_hook =
|
||||
&profile.hooks.as_ref().unwrap_or(&settings.hooks).post_exit;
|
||||
// Post post exit hooks
|
||||
let post_exit_hook =
|
||||
&profile.hooks.as_ref().unwrap_or(&settings.hooks).post_exit;
|
||||
|
||||
let post_exit_hook = if let Some(hook) = post_exit_hook {
|
||||
let mut cmd = hook.split(' ');
|
||||
if let Some(command) = cmd.next() {
|
||||
let mut command = Command::new(command);
|
||||
command.args(&cmd.collect::<Vec<&str>>()).current_dir(path);
|
||||
Some(command)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
let post_exit_hook = if let Some(hook) = post_exit_hook {
|
||||
let mut cmd = hook.split(' ');
|
||||
if let Some(command) = cmd.next() {
|
||||
let mut command = Command::new(command);
|
||||
command.args(&cmd.collect::<Vec<&str>>()).current_dir(path);
|
||||
Some(command)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
}
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let mc_process = crate::launcher::launch_minecraft(
|
||||
java_args,
|
||||
env_args,
|
||||
wrapper,
|
||||
&memory,
|
||||
&resolution,
|
||||
credentials,
|
||||
post_exit_hook,
|
||||
&profile,
|
||||
)
|
||||
.await?;
|
||||
Ok(mc_process)
|
||||
})
|
||||
.await
|
||||
let mc_process = crate::launcher::launch_minecraft(
|
||||
java_args,
|
||||
env_args,
|
||||
wrapper,
|
||||
&memory,
|
||||
&resolution,
|
||||
credentials,
|
||||
post_exit_hook,
|
||||
&profile,
|
||||
)
|
||||
.await?;
|
||||
Ok(mc_process)
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ pub async fn profile_create_empty() -> crate::Result<PathBuf> {
|
||||
// Creates a profile at the given filepath and adds it to the in-memory state
|
||||
// Returns filepath at which it can be accessed in the State
|
||||
#[tracing::instrument]
|
||||
#[theseus_macros::debug_pin]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub async fn profile_create(
|
||||
name: String, // the name of the profile, and relative path
|
||||
@@ -52,92 +53,91 @@ pub async fn profile_create(
|
||||
) -> crate::Result<PathBuf> {
|
||||
trace!("Creating new profile. {}", name);
|
||||
let state = State::get().await?;
|
||||
Box::pin(async move {
|
||||
let uuid = Uuid::new_v4();
|
||||
let path = state.directories.profiles_dir().join(uuid.to_string());
|
||||
if path.exists() {
|
||||
if !path.is_dir() {
|
||||
return Err(ProfileCreationError::NotFolder.into());
|
||||
}
|
||||
if path.join("profile.json").exists() {
|
||||
return Err(ProfileCreationError::ProfileExistsError(
|
||||
path.join("profile.json"),
|
||||
)
|
||||
.into());
|
||||
}
|
||||
|
||||
if ReadDirStream::new(fs::read_dir(&path).await?)
|
||||
.next()
|
||||
.await
|
||||
.is_some()
|
||||
{
|
||||
return Err(ProfileCreationError::NotEmptyFolder.into());
|
||||
}
|
||||
} else {
|
||||
fs::create_dir_all(&path).await?;
|
||||
let uuid = Uuid::new_v4();
|
||||
let path = state.directories.profiles_dir().join(uuid.to_string());
|
||||
if path.exists() {
|
||||
if !path.is_dir() {
|
||||
return Err(ProfileCreationError::NotFolder.into());
|
||||
}
|
||||
|
||||
info!(
|
||||
"Creating profile at path {}",
|
||||
&canonicalize(&path)?.display()
|
||||
);
|
||||
let loader = if modloader != ModLoader::Vanilla {
|
||||
get_loader_version_from_loader(
|
||||
game_version.clone(),
|
||||
modloader,
|
||||
loader_version,
|
||||
if path.join("profile.json").exists() {
|
||||
return Err(ProfileCreationError::ProfileExistsError(
|
||||
path.join("profile.json"),
|
||||
)
|
||||
.await?
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
// Fully canonicalize now that its created for storing purposes
|
||||
let path = canonicalize(&path)?;
|
||||
let mut profile =
|
||||
Profile::new(uuid, name, game_version, path.clone()).await?;
|
||||
if let Some(ref icon) = icon {
|
||||
let bytes = tokio::fs::read(icon).await?;
|
||||
profile
|
||||
.set_icon(
|
||||
&state.directories.caches_dir(),
|
||||
&state.io_semaphore,
|
||||
bytes::Bytes::from(bytes),
|
||||
&icon.to_string_lossy(),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
profile.metadata.icon_url = icon_url;
|
||||
if let Some(loader_version) = loader {
|
||||
profile.metadata.loader = modloader;
|
||||
profile.metadata.loader_version = Some(loader_version);
|
||||
.into());
|
||||
}
|
||||
|
||||
profile.metadata.linked_data = linked_data;
|
||||
|
||||
emit_profile(
|
||||
uuid,
|
||||
path.clone(),
|
||||
&profile.metadata.name,
|
||||
ProfilePayloadType::Created,
|
||||
)
|
||||
.await?;
|
||||
|
||||
if ReadDirStream::new(fs::read_dir(&path).await?)
|
||||
.next()
|
||||
.await
|
||||
.is_some()
|
||||
{
|
||||
let mut profiles = state.profiles.write().await;
|
||||
profiles.insert(profile.clone()).await?;
|
||||
return Err(ProfileCreationError::NotEmptyFolder.into());
|
||||
}
|
||||
} else {
|
||||
fs::create_dir_all(&path).await?;
|
||||
}
|
||||
|
||||
if !skip_install_profile.unwrap_or(false) {
|
||||
crate::launcher::install_minecraft(&profile, None).await?;
|
||||
}
|
||||
State::sync().await?;
|
||||
info!(
|
||||
"Creating profile at path {}",
|
||||
&canonicalize(&path)?.display()
|
||||
);
|
||||
let loader = if modloader != ModLoader::Vanilla {
|
||||
get_loader_version_from_loader(
|
||||
game_version.clone(),
|
||||
modloader,
|
||||
loader_version,
|
||||
)
|
||||
.await?
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
Ok(path)
|
||||
})
|
||||
.await
|
||||
// Fully canonicalize now that its created for storing purposes
|
||||
let path = canonicalize(&path)?;
|
||||
let mut profile =
|
||||
Profile::new(uuid, name, game_version, path.clone()).await?;
|
||||
if let Some(ref icon) = icon {
|
||||
let bytes = tokio::fs::read(icon).await?;
|
||||
profile
|
||||
.set_icon(
|
||||
&state.directories.caches_dir(),
|
||||
&state.io_semaphore,
|
||||
bytes::Bytes::from(bytes),
|
||||
&icon.to_string_lossy(),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
profile.metadata.icon_url = icon_url;
|
||||
if let Some(loader_version) = loader {
|
||||
profile.metadata.loader = modloader;
|
||||
profile.metadata.loader_version = Some(loader_version);
|
||||
}
|
||||
|
||||
profile.metadata.linked_data = linked_data;
|
||||
|
||||
emit_profile(
|
||||
uuid,
|
||||
path.clone(),
|
||||
&profile.metadata.name,
|
||||
ProfilePayloadType::Created,
|
||||
)
|
||||
.await?;
|
||||
|
||||
{
|
||||
let mut profiles = state.profiles.write().await;
|
||||
profiles.insert(profile.clone()).await?;
|
||||
}
|
||||
|
||||
if !skip_install_profile.unwrap_or(false) {
|
||||
crate::launcher::install_minecraft(&profile, None).await?;
|
||||
}
|
||||
State::sync().await?;
|
||||
|
||||
Ok(path)
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
#[theseus_macros::debug_pin]
|
||||
pub(crate) async fn get_loader_version_from_loader(
|
||||
game_version: String,
|
||||
loader: ModLoader,
|
||||
|
||||
Reference in New Issue
Block a user