mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-23 13:11:14 +10:00
fix: Remote tauri dependency from process
Signed-off-by: quexeky <git@quexeky.dev>
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -4286,7 +4286,6 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"serde_with",
|
"serde_with",
|
||||||
"shared_child",
|
"shared_child",
|
||||||
"tauri",
|
|
||||||
"tauri-plugin-opener",
|
"tauri-plugin-opener",
|
||||||
"utils",
|
"utils",
|
||||||
]
|
]
|
||||||
|
|||||||
@ -14,6 +14,5 @@ page_size = "0.6.0"
|
|||||||
serde = "1.0.228"
|
serde = "1.0.228"
|
||||||
serde_with = "3.15.0"
|
serde_with = "3.15.0"
|
||||||
shared_child = "1.1.1"
|
shared_child = "1.1.1"
|
||||||
tauri = "2.8.5"
|
|
||||||
tauri-plugin-opener = "2.5.0"
|
tauri-plugin-opener = "2.5.0"
|
||||||
utils = { version = "0.1.0", path = "../utils" }
|
utils = { version = "0.1.0", path = "../utils" }
|
||||||
|
|||||||
@ -7,6 +7,7 @@ use crate::process_manager::ProcessManager;
|
|||||||
|
|
||||||
pub static PROCESS_MANAGER: LazyLock<Mutex<ProcessManager>> =
|
pub static PROCESS_MANAGER: LazyLock<Mutex<ProcessManager>> =
|
||||||
LazyLock::new(|| Mutex::new(ProcessManager::new()));
|
LazyLock::new(|| Mutex::new(ProcessManager::new()));
|
||||||
|
|
||||||
pub mod error;
|
pub mod error;
|
||||||
pub mod format;
|
pub mod format;
|
||||||
pub mod process_handlers;
|
pub mod process_handlers;
|
||||||
|
|||||||
@ -1,13 +1,6 @@
|
|||||||
use std::{
|
|
||||||
ffi::OsStr,
|
|
||||||
path::PathBuf,
|
|
||||||
process::{Command, Stdio},
|
|
||||||
sync::LazyLock,
|
|
||||||
};
|
|
||||||
|
|
||||||
use client::compat::{COMPAT_INFO, UMU_LAUNCHER_EXECUTABLE};
|
use client::compat::{COMPAT_INFO, UMU_LAUNCHER_EXECUTABLE};
|
||||||
use database::{platform::Platform, Database, DownloadableMetadata, GameVersion};
|
use database::{platform::Platform, Database, DownloadableMetadata, GameVersion};
|
||||||
use log::{debug, info};
|
use log::debug;
|
||||||
|
|
||||||
|
|
||||||
use crate::{error::ProcessError, process_manager::ProcessHandler};
|
use crate::{error::ProcessError, process_manager::ProcessHandler};
|
||||||
|
|||||||
@ -1,28 +1,31 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
fs::{OpenOptions, create_dir_all},
|
fs::{OpenOptions, create_dir_all},
|
||||||
io::{self},
|
io,
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
process::{Command, ExitStatus},
|
process::{Command, ExitStatus},
|
||||||
str::FromStr,
|
str::FromStr,
|
||||||
sync::{Arc, Mutex},
|
sync::Arc,
|
||||||
thread::spawn,
|
|
||||||
time::{Duration, SystemTime},
|
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::Format;
|
||||||
use dynfmt::SimpleCurlyFormat;
|
use dynfmt::SimpleCurlyFormat;
|
||||||
use games::{library::push_game_update, state::GameStatusManager};
|
use games::state::GameStatusManager;
|
||||||
use log::{debug, info, warn};
|
use log::{debug, info, warn};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use shared_child::SharedChild;
|
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 {
|
pub struct RunningProcess {
|
||||||
handle: Arc<SharedChild>,
|
handle: Arc<SharedChild>,
|
||||||
@ -101,7 +104,11 @@ impl ProcessManager<'_> {
|
|||||||
self.log_output_dir.join(game_id)
|
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) {
|
if !self.processes.contains_key(&game_id) {
|
||||||
warn!(
|
warn!(
|
||||||
"process on_finish was called, but game_id is no longer valid. finished with result: {result:?}"
|
"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()
|
process_handler.is_ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn launch_process(
|
/// Must be called through spawn as it is currently blocking
|
||||||
&mut self,
|
pub fn launch_process(&mut self, game_id: String) -> Result<(), ProcessError> {
|
||||||
game_id: String,
|
|
||||||
) -> Result<(), ProcessError> {
|
|
||||||
if self.processes.contains_key(&game_id) {
|
if self.processes.contains_key(&game_id) {
|
||||||
return Err(ProcessError::AlreadyRunning);
|
return Err(ProcessError::AlreadyRunning);
|
||||||
}
|
}
|
||||||
@ -369,13 +374,6 @@ impl ProcessManager<'_> {
|
|||||||
let wait_thread_handle = launch_process_handle.clone();
|
let wait_thread_handle = launch_process_handle.clone();
|
||||||
let wait_thread_game_id = meta.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(
|
self.processes.insert(
|
||||||
meta.id,
|
meta.id,
|
||||||
RunningProcess {
|
RunningProcess {
|
||||||
@ -384,7 +382,12 @@ impl ProcessManager<'_> {
|
|||||||
manually_killed: false,
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user