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,14 +1,14 @@
//! Theseus profile management interface
use crate::launcher::get_loader_version_from_profile;
use crate::settings::Hooks;
use crate::state::{LinkedData, ProfileInstallStage};
use crate::state::{LauncherFeatureVersion, LinkedData, ProfileInstallStage};
use crate::util::io::{self, canonicalize};
use crate::{ErrorKind, pack, profile};
pub use crate::{State, state::Profile};
use crate::{
event::{emit::emit_profile, ProfilePayloadType},
event::{ProfilePayloadType, emit::emit_profile},
prelude::ModLoader,
};
use crate::{pack, profile, ErrorKind};
pub use crate::{state::Profile, State};
use chrono::Utc;
use std::path::PathBuf;
use tracing::{info, trace};
@@ -74,9 +74,11 @@ pub async fn profile_create(
let mut profile = Profile {
path: path.clone(),
install_stage: ProfileInstallStage::NotInstalled,
launcher_feature_version: LauncherFeatureVersion::MOST_RECENT,
name,
icon_path: None,
game_version,
protocol_version: None,
loader: modloader,
loader_version: loader.map(|x| x.id),
groups: Vec::new(),

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

View File

@@ -1,13 +1,13 @@
use crate::state::CacheBehaviour;
use crate::{
LoadingBarType,
event::{
emit::{emit_profile, init_loading},
ProfilePayloadType,
emit::{emit_profile, init_loading},
},
pack::{self, install_from::generate_pack_from_version_id},
profile::get,
state::ProfileInstallStage,
LoadingBarType,
};
use futures::try_join;
@@ -24,9 +24,9 @@ pub async fn update_managed_modrinth_version(
})?;
let unmanaged_err = || {
crate::ErrorKind::InputError(
format!("Profile at {} is not a managed modrinth pack, or has been disconnected.", profile_path),
)
crate::ErrorKind::InputError(format!(
"Profile at {profile_path} is not a managed modrinth pack, or has been disconnected."
))
};
// Extract modrinth pack information, if appropriate
@@ -58,9 +58,9 @@ pub async fn repair_managed_modrinth(profile_path: &str) -> crate::Result<()> {
})?;
let unmanaged_err = || {
crate::ErrorKind::InputError(
format!("Profile at {} is not a managed modrinth pack, or has been disconnected.", profile_path),
)
crate::ErrorKind::InputError(format!(
"Profile at {profile_path} is not a managed modrinth pack, or has been disconnected."
))
};
// For repairing specifically, first we remove all installed projects (to ensure we do remove ones that aren't in the pack)