chore: add validation for OpenTabletDriver path and improve process handling
This commit is contained in:
4 files changed
+66
-23
No files matched your search
@@ -993,10 +993,14 @@ pub async fn run_open_tablet_driver(path: String) -> Result<(), String> {
|
||||
|
||||
#[cfg(windows)]
|
||||
{
|
||||
const DETACHED_PROCESS: u32 = 0x00000008;
|
||||
const CREATE_NEW_PROCESS_GROUP: u32 = 0x00000200;
|
||||
use std::process::Stdio;
|
||||
const CREATE_NO_WINDOW: u32 = 0x08000000;
|
||||
|
||||
Command::new(&otd_path)
|
||||
.creation_flags(DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP)
|
||||
.creation_flags(CREATE_NO_WINDOW)
|
||||
.stdin(Stdio::null())
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::null())
|
||||
.spawn()
|
||||
.map_err(|e| format!("Failed to start OpenTabletDriver: {}", e))?;
|
||||
}
|
||||
@@ -1041,6 +1045,21 @@ pub fn is_open_tablet_driver_running() -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn is_open_tablet_driver_path_valid(app: AppHandle, path: String) -> bool {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
app.fs_scope().allow_file(&path).ok();
|
||||
let otd_path = PathBuf::from(&path);
|
||||
otd_path.exists()
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Clone)]
|
||||
pub struct ExtractProgress {
|
||||
pub theme_name: String,
|
||||
|
||||
@@ -14,10 +14,10 @@ use crate::commands::{
|
||||
find_osu_installation, get_beatmapsets_count, get_ezpp_launcher_update_files, get_hwid,
|
||||
get_launcher_version, get_osu_release_stream, get_osu_skin, get_osu_version, get_platform,
|
||||
get_skins, get_skins_count, has_net8, has_osuwinello, has_wmctrl, install_ezpp_launcher_update,
|
||||
is_open_tablet_driver_running, is_osu_running, open_url_in_browser, opened_urls,
|
||||
presence_connect, presence_disconnect, presence_is_connected, presence_update_button,
|
||||
presence_update_status, presence_update_user, read_theme_info, replace_ui_files,
|
||||
run_open_tablet_driver, run_osu, run_osu_updater, set_osu_config_values,
|
||||
is_open_tablet_driver_path_valid, is_open_tablet_driver_running, is_osu_running,
|
||||
open_url_in_browser, opened_urls, presence_connect, presence_disconnect, presence_is_connected,
|
||||
presence_update_button, presence_update_status, presence_update_user, read_theme_info,
|
||||
replace_ui_files, run_open_tablet_driver, run_osu, run_osu_updater, set_osu_config_values,
|
||||
set_osu_user_config_values, stop_open_tablet_driver, valid_osu_folder,
|
||||
};
|
||||
|
||||
@@ -123,7 +123,8 @@ pub fn run() {
|
||||
download_and_extract_theme,
|
||||
run_open_tablet_driver,
|
||||
stop_open_tablet_driver,
|
||||
is_open_tablet_driver_running
|
||||
is_open_tablet_driver_running,
|
||||
is_open_tablet_driver_path_valid
|
||||
])
|
||||
.plugin(tauri_plugin_fs::init())
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
|
||||
Reference in new issue
Block a user