mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-10 04:22:13 +10:00
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -4288,6 +4288,7 @@ dependencies = [
|
||||
"serde",
|
||||
"serde_with",
|
||||
"shared_child",
|
||||
"tauri",
|
||||
"tauri-plugin-opener",
|
||||
"utils",
|
||||
]
|
||||
|
||||
@ -14,5 +14,6 @@ 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" }
|
||||
|
||||
@ -1,14 +1,41 @@
|
||||
#![feature(nonpoison_mutex)]
|
||||
#![feature(sync_nonpoison)]
|
||||
|
||||
use std::sync::{LazyLock, nonpoison::Mutex};
|
||||
use std::{
|
||||
ops::Deref,
|
||||
sync::{LazyLock, OnceLock, nonpoison::Mutex},
|
||||
};
|
||||
|
||||
use tauri::AppHandle;
|
||||
|
||||
use crate::process_manager::ProcessManager;
|
||||
|
||||
pub static PROCESS_MANAGER: LazyLock<Mutex<ProcessManager>> =
|
||||
LazyLock::new(|| Mutex::new(ProcessManager::new()));
|
||||
pub static PROCESS_MANAGER: ProcessManagerWrapper = ProcessManagerWrapper::new();
|
||||
|
||||
pub mod error;
|
||||
pub mod format;
|
||||
pub mod process_handlers;
|
||||
pub mod process_manager;
|
||||
|
||||
pub struct ProcessManagerWrapper(OnceLock<Mutex<ProcessManager<'static>>>);
|
||||
impl ProcessManagerWrapper {
|
||||
const fn new() -> Self {
|
||||
ProcessManagerWrapper(OnceLock::new())
|
||||
}
|
||||
pub fn init(app_handle: AppHandle) {
|
||||
PROCESS_MANAGER
|
||||
.0
|
||||
.set(Mutex::new(ProcessManager::new(app_handle)))
|
||||
.unwrap_or_else(|_| panic!("Failed to initialise Process Manager")); // Using panic! here because we can't implement Debug
|
||||
}
|
||||
}
|
||||
impl Deref for ProcessManagerWrapper {
|
||||
type Target = Mutex<ProcessManager<'static>>;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
match self.0.get() {
|
||||
Some(process_manager) => process_manager,
|
||||
None => unreachable!("Download manager should always be initialised"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ use std::{
|
||||
process::{Command, ExitStatus},
|
||||
str::FromStr,
|
||||
sync::Arc,
|
||||
thread::spawn,
|
||||
time::{Duration, SystemTime},
|
||||
};
|
||||
|
||||
@ -15,10 +16,11 @@ use database::{
|
||||
};
|
||||
use dynfmt::Format;
|
||||
use dynfmt::SimpleCurlyFormat;
|
||||
use games::state::GameStatusManager;
|
||||
use games::{library::push_game_update, state::GameStatusManager};
|
||||
use log::{debug, info, warn};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use shared_child::SharedChild;
|
||||
use tauri::AppHandle;
|
||||
|
||||
use crate::{
|
||||
PROCESS_MANAGER,
|
||||
@ -41,10 +43,11 @@ pub struct ProcessManager<'a> {
|
||||
(Platform, Platform),
|
||||
&'a (dyn ProcessHandler + Sync + Send + 'static),
|
||||
)>,
|
||||
app_handle: AppHandle,
|
||||
}
|
||||
|
||||
impl ProcessManager<'_> {
|
||||
pub fn new() -> Self {
|
||||
pub fn new(app_handle: AppHandle) -> Self {
|
||||
let log_output_dir = DATA_ROOT_DIR.join("logs");
|
||||
|
||||
ProcessManager {
|
||||
@ -82,6 +85,7 @@ impl ProcessManager<'_> {
|
||||
&UMULauncher {} as &(dyn ProcessHandler + Sync + Send + 'static),
|
||||
),
|
||||
],
|
||||
app_handle,
|
||||
}
|
||||
}
|
||||
|
||||
@ -172,13 +176,12 @@ impl ProcessManager<'_> {
|
||||
|
||||
let status = GameStatusManager::fetch_state(&game_id, &db_handle);
|
||||
|
||||
// TODO
|
||||
// push_game_update(
|
||||
// &self.app_handle,
|
||||
// &game_id,
|
||||
// Some(version_data.clone()),
|
||||
// status,
|
||||
// );
|
||||
push_game_update(
|
||||
&self.app_handle,
|
||||
&game_id,
|
||||
Some(version_data.clone()),
|
||||
status,
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -363,13 +366,12 @@ impl ProcessManager<'_> {
|
||||
.transient_statuses
|
||||
.insert(meta.clone(), ApplicationTransientStatus::Running {});
|
||||
|
||||
// TODO
|
||||
// push_game_update(
|
||||
// &self.app_handle,
|
||||
// &meta.id,
|
||||
// None,
|
||||
// (None, Some(ApplicationTransientStatus::Running {})),
|
||||
// );
|
||||
push_game_update(
|
||||
&self.app_handle,
|
||||
&meta.id,
|
||||
None,
|
||||
(None, Some(ApplicationTransientStatus::Running {})),
|
||||
);
|
||||
|
||||
let wait_thread_handle = launch_process_handle.clone();
|
||||
let wait_thread_game_id = meta.clone();
|
||||
@ -382,12 +384,14 @@ impl ProcessManager<'_> {
|
||||
manually_killed: false,
|
||||
},
|
||||
);
|
||||
spawn(move || {
|
||||
let result: Result<ExitStatus, std::io::Error> = launch_process_handle.wait();
|
||||
|
||||
let result: Result<ExitStatus, std::io::Error> = launch_process_handle.wait();
|
||||
|
||||
PROCESS_MANAGER
|
||||
.lock()
|
||||
.on_process_finish(wait_thread_game_id.id, result)
|
||||
PROCESS_MANAGER
|
||||
.lock()
|
||||
.on_process_finish(wait_thread_game_id.id, result)
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -22,7 +22,9 @@ use std::{
|
||||
use ::client::{
|
||||
app_status::AppStatus, autostart::sync_autostart_on_startup, compat::CompatInfo, user::User,
|
||||
};
|
||||
use ::download_manager::DownloadManagerWrapper;
|
||||
use ::games::{library::Game, scan::scan_install_dirs};
|
||||
use ::process::ProcessManagerWrapper;
|
||||
use ::remote::{
|
||||
auth::{self, generate_authorization_header, HandshakeRequestBody, HandshakeResponse},
|
||||
cache::clear_cached_object,
|
||||
@ -116,6 +118,9 @@ async fn setup(handle: AppHandle) -> AppState {
|
||||
|
||||
let games = HashMap::new();
|
||||
|
||||
ProcessManagerWrapper::init(handle.clone());
|
||||
DownloadManagerWrapper::init(handle.clone());
|
||||
|
||||
debug!("checking if database is set up");
|
||||
let is_set_up = DB.database_is_set_up();
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use std::sync::Mutex;
|
||||
use std::sync::nonpoison::Mutex;
|
||||
|
||||
use process::{error::ProcessError, PROCESS_MANAGER};
|
||||
use tauri::AppHandle;
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
"beforeDevCommand": "yarn --cwd main dev --port 1432",
|
||||
"devUrl": "http://localhost:1432/",
|
||||
"beforeBuildCommand": "yarn build",
|
||||
"frontendDist": "../../.output"
|
||||
"frontendDist": "../.output"
|
||||
},
|
||||
"app": {
|
||||
"security": {
|
||||
|
||||
Reference in New Issue
Block a user