You've already forked AstralRinth
forked from didirus/AstralRinth
Folder names (#318)
This commit is contained in:
@@ -50,7 +50,18 @@ pub async fn logs_get_output_by_datetime(
|
||||
profile_uuid: Uuid,
|
||||
datetime_string: String,
|
||||
) -> Result<String> {
|
||||
Ok(logs::get_output_by_datetime(profile_uuid, &datetime_string).await?)
|
||||
let profile_path = if let Some(p) =
|
||||
crate::profile::get_by_uuid(profile_uuid, None).await?
|
||||
{
|
||||
p.profile_id()
|
||||
} else {
|
||||
return Err(theseus::Error::from(
|
||||
theseus::ErrorKind::UnmanagedProfileError(profile_uuid.to_string()),
|
||||
)
|
||||
.into());
|
||||
};
|
||||
|
||||
Ok(logs::get_output_by_datetime(&profile_path, &datetime_string).await?)
|
||||
}
|
||||
|
||||
/// Delete all logs for a profile by profile id
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::api::Result;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use theseus::{
|
||||
pack::{
|
||||
install::install_pack,
|
||||
@@ -20,8 +20,8 @@ pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
|
||||
#[tauri::command]
|
||||
pub async fn pack_install(
|
||||
location: CreatePackLocation,
|
||||
profile: PathBuf,
|
||||
) -> Result<PathBuf> {
|
||||
profile: ProfilePathId,
|
||||
) -> Result<ProfilePathId> {
|
||||
Ok(install_pack(location, profile).await?)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use crate::api::Result;
|
||||
use theseus::prelude::*;
|
||||
use uuid::Uuid;
|
||||
@@ -50,14 +48,15 @@ pub async fn process_get_all_running_uuids() -> Result<Vec<Uuid>> {
|
||||
// Gets all process UUIDs by profile path
|
||||
#[tauri::command]
|
||||
pub async fn process_get_uuids_by_profile_path(
|
||||
profile_path: &Path,
|
||||
profile_path: ProfilePathId,
|
||||
) -> Result<Vec<Uuid>> {
|
||||
Ok(process::get_uuids_by_profile_path(profile_path).await?)
|
||||
}
|
||||
|
||||
// Gets the Profile paths of each *running* stored process in the state
|
||||
#[tauri::command]
|
||||
pub async fn process_get_all_running_profile_paths() -> Result<Vec<PathBuf>> {
|
||||
pub async fn process_get_all_running_profile_paths(
|
||||
) -> Result<Vec<ProfilePathId>> {
|
||||
Ok(process::get_all_running_profile_paths().await?)
|
||||
}
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
|
||||
// Remove a profile
|
||||
// invoke('plugin:profile|profile_add_path',path)
|
||||
#[tauri::command]
|
||||
pub async fn profile_remove(path: &Path) -> Result<()> {
|
||||
profile::remove(path).await?;
|
||||
pub async fn profile_remove(path: ProfilePathId) -> Result<()> {
|
||||
profile::remove(&path).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -45,19 +45,19 @@ pub async fn profile_remove(path: &Path) -> Result<()> {
|
||||
// invoke('plugin:profile|profile_add_path',path)
|
||||
#[tauri::command]
|
||||
pub async fn profile_get(
|
||||
path: &Path,
|
||||
path: ProfilePathId,
|
||||
clear_projects: Option<bool>,
|
||||
) -> Result<Option<Profile>> {
|
||||
let res = profile::get(path, clear_projects).await?;
|
||||
let res = profile::get(&path, clear_projects).await?;
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
// Get optimal java version from profile
|
||||
#[tauri::command]
|
||||
pub async fn profile_get_optimal_jre_key(
|
||||
path: &Path,
|
||||
path: ProfilePathId,
|
||||
) -> Result<Option<JavaVersion>> {
|
||||
let res = profile::get_optimal_jre_key(path).await?;
|
||||
let res = profile::get_optimal_jre_key(&path).await?;
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
@@ -66,14 +66,14 @@ pub async fn profile_get_optimal_jre_key(
|
||||
#[tauri::command]
|
||||
pub async fn profile_list(
|
||||
clear_projects: Option<bool>,
|
||||
) -> Result<HashMap<PathBuf, Profile>> {
|
||||
) -> Result<HashMap<ProfilePathId, Profile>> {
|
||||
let res = profile::list(clear_projects).await?;
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn profile_check_installed(
|
||||
path: &Path,
|
||||
path: ProfilePathId,
|
||||
project_id: String,
|
||||
) -> Result<bool> {
|
||||
let profile = profile_get(path, None).await?;
|
||||
@@ -94,8 +94,8 @@ pub async fn profile_check_installed(
|
||||
/// Installs/Repairs a profile
|
||||
/// invoke('plugin:profile|profile_install')
|
||||
#[tauri::command]
|
||||
pub async fn profile_install(path: &Path) -> Result<()> {
|
||||
profile::install(path).await?;
|
||||
pub async fn profile_install(path: ProfilePathId) -> Result<()> {
|
||||
profile::install(&path).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -103,40 +103,40 @@ pub async fn profile_install(path: &Path) -> Result<()> {
|
||||
/// invoke('plugin:profile|profile_update_all')
|
||||
#[tauri::command]
|
||||
pub async fn profile_update_all(
|
||||
path: &Path,
|
||||
) -> Result<HashMap<PathBuf, PathBuf>> {
|
||||
Ok(profile::update_all(path).await?)
|
||||
path: ProfilePathId,
|
||||
) -> Result<HashMap<ProjectPathId, ProjectPathId>> {
|
||||
Ok(profile::update_all(&path).await?)
|
||||
}
|
||||
|
||||
/// Updates a specified project
|
||||
/// invoke('plugin:profile|profile_update_project')
|
||||
#[tauri::command]
|
||||
pub async fn profile_update_project(
|
||||
path: &Path,
|
||||
project_path: &Path,
|
||||
) -> Result<PathBuf> {
|
||||
Ok(profile::update_project(path, project_path, None).await?)
|
||||
path: ProfilePathId,
|
||||
project_path: ProjectPathId,
|
||||
) -> Result<ProjectPathId> {
|
||||
Ok(profile::update_project(&path, &project_path, None).await?)
|
||||
}
|
||||
|
||||
// Adds a project to a profile from a version ID
|
||||
// invoke('plugin:profile|profile_add_project_from_version')
|
||||
#[tauri::command]
|
||||
pub async fn profile_add_project_from_version(
|
||||
path: &Path,
|
||||
path: ProfilePathId,
|
||||
version_id: String,
|
||||
) -> Result<PathBuf> {
|
||||
Ok(profile::add_project_from_version(path, version_id).await?)
|
||||
) -> Result<ProjectPathId> {
|
||||
Ok(profile::add_project_from_version(&path, version_id).await?)
|
||||
}
|
||||
|
||||
// Adds a project to a profile from a path
|
||||
// invoke('plugin:profile|profile_add_project_from_path')
|
||||
#[tauri::command]
|
||||
pub async fn profile_add_project_from_path(
|
||||
path: &Path,
|
||||
path: ProfilePathId,
|
||||
project_path: &Path,
|
||||
project_type: Option<String>,
|
||||
) -> Result<PathBuf> {
|
||||
let res = profile::add_project_from_path(path, project_path, project_type)
|
||||
) -> Result<ProjectPathId> {
|
||||
let res = profile::add_project_from_path(&path, project_path, project_type)
|
||||
.await?;
|
||||
Ok(res)
|
||||
}
|
||||
@@ -145,20 +145,20 @@ pub async fn profile_add_project_from_path(
|
||||
// invoke('plugin:profile|profile_toggle_disable_project')
|
||||
#[tauri::command]
|
||||
pub async fn profile_toggle_disable_project(
|
||||
path: &Path,
|
||||
project_path: &Path,
|
||||
) -> Result<PathBuf> {
|
||||
Ok(profile::toggle_disable_project(path, project_path).await?)
|
||||
path: ProfilePathId,
|
||||
project_path: ProjectPathId,
|
||||
) -> Result<ProjectPathId> {
|
||||
Ok(profile::toggle_disable_project(&path, &project_path).await?)
|
||||
}
|
||||
|
||||
// Removes a project from a profile
|
||||
// invoke('plugin:profile|profile_remove_project')
|
||||
#[tauri::command]
|
||||
pub async fn profile_remove_project(
|
||||
path: &Path,
|
||||
project_path: &Path,
|
||||
path: ProfilePathId,
|
||||
project_path: ProjectPathId,
|
||||
) -> Result<()> {
|
||||
profile::remove_project(path, project_path).await?;
|
||||
profile::remove_project(&path, &project_path).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -166,13 +166,13 @@ pub async fn profile_remove_project(
|
||||
// invoke('profile_export_mrpack')
|
||||
#[tauri::command]
|
||||
pub async fn profile_export_mrpack(
|
||||
path: &Path,
|
||||
path: ProfilePathId,
|
||||
export_location: PathBuf,
|
||||
included_overrides: Vec<String>,
|
||||
version_id: Option<String>,
|
||||
) -> Result<()> {
|
||||
profile::export_mrpack(
|
||||
path,
|
||||
&path,
|
||||
export_location,
|
||||
included_overrides,
|
||||
version_id,
|
||||
@@ -190,7 +190,7 @@ pub async fn profile_export_mrpack(
|
||||
// => [folder1, folder2]
|
||||
#[tauri::command]
|
||||
pub async fn profile_get_potential_override_folders(
|
||||
profile_path: PathBuf,
|
||||
profile_path: ProfilePathId,
|
||||
) -> Result<Vec<PathBuf>> {
|
||||
let overrides =
|
||||
profile::get_potential_override_folders(profile_path).await?;
|
||||
@@ -202,8 +202,8 @@ pub async fn profile_get_potential_override_folders(
|
||||
// for the actual Child in the state.
|
||||
// invoke('plugin:profile|profile_run', path)
|
||||
#[tauri::command]
|
||||
pub async fn profile_run(path: &Path) -> Result<Uuid> {
|
||||
let minecraft_child = profile::run(path).await?;
|
||||
pub async fn profile_run(path: ProfilePathId) -> Result<Uuid> {
|
||||
let minecraft_child = profile::run(&path).await?;
|
||||
let uuid = minecraft_child.read().await.uuid;
|
||||
Ok(uuid)
|
||||
}
|
||||
@@ -211,8 +211,8 @@ pub async fn profile_run(path: &Path) -> Result<Uuid> {
|
||||
// Run Minecraft using a profile using the default credentials, and wait for the result
|
||||
// invoke('plugin:profile|profile_run_wait', path)
|
||||
#[tauri::command]
|
||||
pub async fn profile_run_wait(path: &Path) -> Result<()> {
|
||||
let proc_lock = profile::run(path).await?;
|
||||
pub async fn profile_run_wait(path: ProfilePathId) -> Result<()> {
|
||||
let proc_lock = profile::run(&path).await?;
|
||||
let mut proc = proc_lock.write().await;
|
||||
Ok(process::wait_for(&mut proc).await?)
|
||||
}
|
||||
@@ -223,11 +223,12 @@ pub async fn profile_run_wait(path: &Path) -> Result<()> {
|
||||
// invoke('plugin:profile|profile_run_credentials', {path, credentials})')
|
||||
#[tauri::command]
|
||||
pub async fn profile_run_credentials(
|
||||
path: &Path,
|
||||
path: ProfilePathId,
|
||||
credentials: Credentials,
|
||||
) -> Result<Uuid> {
|
||||
let minecraft_child = profile::run_credentials(path, &credentials).await?;
|
||||
let minecraft_child = profile::run_credentials(&path, &credentials).await?;
|
||||
let uuid = minecraft_child.read().await.uuid;
|
||||
|
||||
Ok(uuid)
|
||||
}
|
||||
|
||||
@@ -235,10 +236,10 @@ pub async fn profile_run_credentials(
|
||||
// invoke('plugin:profile|profile_run_wait', {path, credentials)
|
||||
#[tauri::command]
|
||||
pub async fn profile_run_wait_credentials(
|
||||
path: &Path,
|
||||
path: ProfilePathId,
|
||||
credentials: Credentials,
|
||||
) -> Result<()> {
|
||||
let proc_lock = profile::run_credentials(path, &credentials).await?;
|
||||
let proc_lock = profile::run_credentials(&path, &credentials).await?;
|
||||
let mut proc = proc_lock.write().await;
|
||||
Ok(process::wait_for(&mut proc).await?)
|
||||
}
|
||||
@@ -265,10 +266,10 @@ pub struct EditProfileMetadata {
|
||||
// invoke('plugin:profile|profile_edit', {path, editProfile})
|
||||
#[tauri::command]
|
||||
pub async fn profile_edit(
|
||||
path: &Path,
|
||||
path: ProfilePathId,
|
||||
edit_profile: EditProfile,
|
||||
) -> Result<()> {
|
||||
profile::edit(path, |prof| {
|
||||
profile::edit(&path, |prof| {
|
||||
if let Some(metadata) = edit_profile.metadata.clone() {
|
||||
if let Some(name) = metadata.name {
|
||||
prof.metadata.name = name;
|
||||
@@ -305,9 +306,9 @@ pub async fn profile_edit(
|
||||
// invoke('plugin:profile|profile_edit_icon')
|
||||
#[tauri::command]
|
||||
pub async fn profile_edit_icon(
|
||||
path: &Path,
|
||||
path: ProfilePathId,
|
||||
icon_path: Option<&Path>,
|
||||
) -> Result<()> {
|
||||
profile::edit_icon(path, icon_path).await?;
|
||||
profile::edit_icon(&path, icon_path).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ pub async fn profile_create(
|
||||
modloader: ModLoader, // the modloader to use
|
||||
loader_version: Option<String>, // the modloader version to use, set to "latest", "stable", or the ID of your chosen loader
|
||||
icon: Option<PathBuf>, // the icon for the profile
|
||||
) -> Result<PathBuf> {
|
||||
) -> Result<ProfilePathId> {
|
||||
let res = profile_create::profile_create(
|
||||
name,
|
||||
game_version,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::api::Result;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use theseus::prelude::*;
|
||||
@@ -22,7 +24,11 @@ pub struct FrontendSettings {
|
||||
|
||||
pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
|
||||
tauri::plugin::Builder::new("settings")
|
||||
.invoke_handler(tauri::generate_handler![settings_get, settings_set,])
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
settings_get,
|
||||
settings_set,
|
||||
settings_change_config_dir
|
||||
])
|
||||
.build()
|
||||
}
|
||||
|
||||
@@ -41,3 +47,12 @@ pub async fn settings_set(settings: Settings) -> Result<()> {
|
||||
settings::set(settings).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Change config directory
|
||||
// Seizes the entire State to do it
|
||||
// invoke('plugin:settings|settings_change_config_dir', new_dir)
|
||||
#[tauri::command]
|
||||
pub async fn settings_change_config_dir(new_config_dir: PathBuf) -> Result<()> {
|
||||
settings::set_config_dir(new_config_dir).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -122,6 +122,6 @@ pub async fn handle_command(command: String) -> Result<()> {
|
||||
#[tauri::command]
|
||||
pub async fn await_sync() -> Result<()> {
|
||||
State::sync().await?;
|
||||
tracing::info!("State synced");
|
||||
tracing::debug!("State synced");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user