fix: Remote tauri dependency from process

Signed-off-by: quexeky <git@quexeky.dev>
This commit is contained in:
quexeky
2025-10-11 09:51:04 +11:00
parent 59f040bc8b
commit 62a2561539
5 changed files with 28 additions and 33 deletions

1
Cargo.lock generated
View File

@ -4286,7 +4286,6 @@ dependencies = [
"serde",
"serde_with",
"shared_child",
"tauri",
"tauri-plugin-opener",
"utils",
]

View File

@ -14,6 +14,5 @@ page_size = "0.6.0"
serde = "1.0.228"
serde_with = "3.15.0"
shared_child = "1.1.1"
tauri = "2.8.5"
tauri-plugin-opener = "2.5.0"
utils = { version = "0.1.0", path = "../utils" }

View File

@ -7,6 +7,7 @@ use crate::process_manager::ProcessManager;
pub static PROCESS_MANAGER: LazyLock<Mutex<ProcessManager>> =
LazyLock::new(|| Mutex::new(ProcessManager::new()));
pub mod error;
pub mod format;
pub mod process_handlers;

View File

@ -1,13 +1,6 @@
use std::{
ffi::OsStr,
path::PathBuf,
process::{Command, Stdio},
sync::LazyLock,
};
use client::compat::{COMPAT_INFO, UMU_LAUNCHER_EXECUTABLE};
use database::{platform::Platform, Database, DownloadableMetadata, GameVersion};
use log::{debug, info};
use log::debug;
use crate::{error::ProcessError, process_manager::ProcessHandler};

View File

@ -1,28 +1,31 @@
use std::{
collections::HashMap,
fs::{OpenOptions, create_dir_all},
io::{self},
io,
path::PathBuf,
process::{Command, ExitStatus},
str::FromStr,
sync::{Arc, Mutex},
thread::spawn,
sync::Arc,
time::{Duration, SystemTime},
};
use database::{borrow_db_checked, borrow_db_mut_checked, db::DATA_ROOT_DIR, platform::Platform, ApplicationTransientStatus, Database, DownloadType, DownloadableMetadata, GameDownloadStatus, GameVersion};
use database::{
ApplicationTransientStatus, Database, DownloadType, DownloadableMetadata, GameDownloadStatus,
GameVersion, borrow_db_checked, borrow_db_mut_checked, db::DATA_ROOT_DIR, platform::Platform,
};
use dynfmt::Format;
use dynfmt::SimpleCurlyFormat;
use games::{library::push_game_update, state::GameStatusManager};
use games::state::GameStatusManager;
use log::{debug, info, warn};
use serde::{Deserialize, Serialize};
use shared_child::SharedChild;
use tauri::{AppHandle, Emitter, Manager};
use tauri_plugin_opener::OpenerExt;
use utils::lock;
use crate::{error::ProcessError, format::DropFormatArgs, process_handlers::{AsahiMuvmLauncher, NativeGameLauncher, UMULauncher}, PROCESS_MANAGER};
use crate::{
PROCESS_MANAGER,
error::ProcessError,
format::DropFormatArgs,
process_handlers::{AsahiMuvmLauncher, NativeGameLauncher, UMULauncher},
};
pub struct RunningProcess {
handle: Arc<SharedChild>,
@ -101,7 +104,11 @@ impl ProcessManager<'_> {
self.log_output_dir.join(game_id)
}
fn on_process_finish(&mut self, game_id: String, result: Result<ExitStatus, std::io::Error>) -> Result<(), ProcessError> {
fn on_process_finish(
&mut self,
game_id: String,
result: Result<ExitStatus, std::io::Error>,
) -> Result<(), ProcessError> {
if !self.processes.contains_key(&game_id) {
warn!(
"process on_finish was called, but game_id is no longer valid. finished with result: {result:?}"
@ -199,10 +206,8 @@ impl ProcessManager<'_> {
process_handler.is_ok()
}
pub fn launch_process(
&mut self,
game_id: String,
) -> Result<(), ProcessError> {
/// Must be called through spawn as it is currently blocking
pub fn launch_process(&mut self, game_id: String) -> Result<(), ProcessError> {
if self.processes.contains_key(&game_id) {
return Err(ProcessError::AlreadyRunning);
}
@ -369,13 +374,6 @@ impl ProcessManager<'_> {
let wait_thread_handle = launch_process_handle.clone();
let wait_thread_game_id = meta.clone();
spawn(move || {
let result: Result<ExitStatus, std::io::Error> = launch_process_handle.wait();
PROCESS_MANAGER.lock().on_process_finish(wait_thread_game_id.id, result);
});
self.processes.insert(
meta.id,
RunningProcess {
@ -384,7 +382,12 @@ impl ProcessManager<'_> {
manually_killed: false,
},
);
Ok(())
let result: Result<ExitStatus, std::io::Error> = launch_process_handle.wait();
PROCESS_MANAGER
.lock()
.on_process_finish(wait_thread_game_id.id, result)
}
}