Merge commit '74cf3f076eff43755bb4bef62f1c1bb3fc0e6c2a' into feature-clean

This commit is contained in:
2025-05-26 17:59:09 +03:00
497 changed files with 15033 additions and 9421 deletions

View File

@@ -1,9 +1,9 @@
//! Theseus profile management interface
use crate::event::LoadingBarType;
use crate::event::emit::{
emit_loading, init_loading, loading_try_for_each_concurrent,
};
use crate::event::LoadingBarType;
use crate::pack::install_from::{
EnvType, PackDependency, PackFile, PackFileHash, PackFormat,
};
@@ -12,10 +12,10 @@ use crate::state::{
ProfileFile, ProfileInstallStage, ProjectType, SideType,
};
use crate::event::{emit::emit_profile, ProfilePayloadType};
use crate::event::{ProfilePayloadType, emit::emit_profile};
use crate::util::fetch;
use crate::util::io::{self, IOError};
pub use crate::{state::Profile, State};
pub use crate::{State, state::Profile};
use async_zip::tokio::write::ZipFileWriter;
use async_zip::{Compression, ZipEntryBuilder};
use serde_json::json;
@@ -36,6 +36,13 @@ use tokio::{fs::File, process::Command, sync::RwLock};
pub mod create;
pub mod update;
#[derive(Debug, Clone)]
pub enum QuickPlayType {
None,
Singleplayer(String),
Server(String),
}
/// Remove a profile
#[tracing::instrument]
pub async fn remove(path: &str) -> crate::Result<()> {
@@ -463,8 +470,7 @@ pub async fn export_mrpack(
state.io_semaphore.0.acquire().await?;
let profile = get(profile_path).await?.ok_or_else(|| {
crate::ErrorKind::OtherError(format!(
"Tried to export a nonexistent or unloaded profile at path {}!",
profile_path
"Tried to export a nonexistent or unloaded profile at path {profile_path}!"
))
})?;
@@ -610,8 +616,7 @@ fn pack_get_relative_path(
.strip_prefix(profile_path)
.map_err(|_| {
crate::ErrorKind::FSError(format!(
"Path {path:?} does not correspond to a profile",
path = path
"Path {path:?} does not correspond to a profile"
))
})?
.components()
@@ -623,14 +628,17 @@ fn pack_get_relative_path(
/// Run Minecraft using a profile and the default credentials, logged in credentials,
/// failing with an error if no credentials are available
#[tracing::instrument]
pub async fn run(path: &str) -> crate::Result<ProcessMetadata> {
pub async fn run(
path: &str,
quick_play_type: &QuickPlayType,
) -> crate::Result<ProcessMetadata> {
let state = State::get().await?;
let default_account = Credentials::get_default_credential(&state.pool)
.await?
.ok_or_else(|| crate::ErrorKind::NoCredentialsError.as_error())?;
run_credentials(path, &default_account).await
run_credentials(path, &default_account, quick_play_type).await
}
/// Run Minecraft using a profile, and credentials for authentication
@@ -640,13 +648,13 @@ pub async fn run(path: &str) -> crate::Result<ProcessMetadata> {
pub async fn run_credentials(
path: &str,
credentials: &Credentials,
quick_play_type: &QuickPlayType,
) -> crate::Result<ProcessMetadata> {
let state = State::get().await?;
let settings = Settings::get(&state.pool).await?;
let profile = get(path).await?.ok_or_else(|| {
crate::ErrorKind::OtherError(format!(
"Tried to run a nonexistent or unloaded profile at path {}!",
path
"Tried to run a nonexistent or unloaded profile at path {path}!"
))
})?;
@@ -719,6 +727,7 @@ pub async fn run_credentials(
credentials,
post_exit_hook,
&profile,
quick_play_type,
)
.await
}
@@ -741,8 +750,7 @@ pub async fn try_update_playtime(path: &str) -> crate::Result<()> {
let profile = get(path).await?.ok_or_else(|| {
crate::ErrorKind::OtherError(format!(
"Tried to update playtime for a nonexistent or unloaded profile at path {}!",
path
"Tried to update playtime for a nonexistent or unloaded profile at path {path}!"
))
})?;
let updated_recent_playtime = profile.recent_time_played;
@@ -823,7 +831,7 @@ pub async fn create_mrpack_json(
return Err(crate::ErrorKind::OtherError(
"Loader version mismatch".to_string(),
)
.into())
.into());
}
};
dependencies