chore: force release stream to stable, connecting to ezppfarm does now work
This commit is contained in:
@@ -216,13 +216,6 @@ pub fn get_osu_release_stream(folder: String) -> String {
|
||||
.unwrap_or_else(|| "Stable40".to_string());
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn get_osu_previous_release_stream(folder: String) -> Option<String> {
|
||||
let path = PathBuf::from(folder);
|
||||
let osu_config = get_osu_config(path.clone());
|
||||
osu_config.and_then(|config| config.get("_PreviousReleaseStream").cloned())
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct ConfigEntry {
|
||||
pub key: String,
|
||||
@@ -261,77 +254,106 @@ pub fn set_osu_config_values(
|
||||
|
||||
#[tauri::command]
|
||||
pub fn run_osu_updater(folder: String) -> Result<(), String> {
|
||||
let osu_exe_path = PathBuf::from(folder.clone()).join("osu!.exe");
|
||||
#[cfg(windows)]
|
||||
const DETACHED_PROCESS: u32 = 0x00000008;
|
||||
#[cfg(windows)]
|
||||
const CREATE_NEW_PROCESS_GROUP: u32 = 0x00000200;
|
||||
|
||||
let handle = thread::spawn(move || {
|
||||
#[cfg(windows)]
|
||||
let mut updater_process = Command::new(&osu_exe_path)
|
||||
.arg("-repair")
|
||||
.creation_flags(DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP)
|
||||
.spawn()
|
||||
.ok()?; // Ignore error, just exit thread
|
||||
|
||||
#[cfg(not(windows))]
|
||||
let mut updater_process = Command::new(&osu_exe_path).arg("-repair").spawn().ok()?; // Ignore error, just exit thread
|
||||
|
||||
thread::sleep(Duration::from_millis(500));
|
||||
|
||||
let mut sys = System::new_all();
|
||||
sys.refresh_processes(sysinfo::ProcessesToUpdate::All, true);
|
||||
|
||||
let mut termination_thread_running = true;
|
||||
|
||||
while termination_thread_running {
|
||||
for (_, process) in sys.processes() {
|
||||
if process.name() == "osu!.exe" {
|
||||
let process_id = process.pid();
|
||||
let window_title = get_window_title_by_pid(process_id);
|
||||
|
||||
if !window_title.is_empty() && !window_title.contains("updater") {
|
||||
if let Ok(_) = process.kill_and_wait() {
|
||||
termination_thread_running = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !termination_thread_running {
|
||||
break;
|
||||
}
|
||||
|
||||
thread::sleep(Duration::from_millis(500));
|
||||
sys.refresh_processes(sysinfo::ProcessesToUpdate::All, true);
|
||||
}
|
||||
|
||||
let _ = updater_process.wait();
|
||||
|
||||
let force_update_files = [".require_update", "help.txt", "_pending"];
|
||||
|
||||
for update_file_name in &force_update_files {
|
||||
let update_file = PathBuf::from(&folder).join(update_file_name);
|
||||
if update_file.exists() {
|
||||
let metadata = std::fs::symlink_metadata(&update_file);
|
||||
if let Ok(meta) = metadata {
|
||||
let result = if meta.is_dir() {
|
||||
std::fs::remove_dir_all(&update_file)
|
||||
} else {
|
||||
std::fs::remove_file(&update_file)
|
||||
};
|
||||
if let Err(e) = result {
|
||||
eprintln!(
|
||||
"Failed to remove force update file {:?}: {}",
|
||||
update_file, e
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some(())
|
||||
});
|
||||
|
||||
handle.join().map_err(|_| "Thread panicked".to_string())?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn run_osu(folder: String) -> Result<(), String> {
|
||||
let osu_exe_path = PathBuf::from(folder).join("osu!.exe");
|
||||
#[cfg(windows)]
|
||||
const DETACHED_PROCESS: u32 = 0x00000008;
|
||||
#[cfg(windows)]
|
||||
const CREATE_NEW_PROCESS_GROUP: u32 = 0x00000200;
|
||||
|
||||
#[cfg(windows)]
|
||||
let mut updater_process = Command::new(osu_exe_path)
|
||||
.arg("-repair")
|
||||
.creation_flags(DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP)
|
||||
.spawn()
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
#[cfg(not(windows))]
|
||||
let mut updater_process = Command::new(osu_exe_path)
|
||||
.arg("-repair")
|
||||
.spawn()
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
thread::sleep(Duration::from_millis(500));
|
||||
|
||||
let mut sys = System::new_all();
|
||||
sys.refresh_processes(sysinfo::ProcessesToUpdate::All, true);
|
||||
|
||||
let mut termination_thread_running = true;
|
||||
|
||||
while termination_thread_running {
|
||||
for (_, process) in sys.processes() {
|
||||
if process.name() == "osu!.exe" {
|
||||
let process_id = process.pid();
|
||||
let window_title = get_window_title_by_pid(process_id);
|
||||
|
||||
if !window_title.is_empty() && !window_title.contains("updater") {
|
||||
if let Ok(_) = process.kill_and_wait() {
|
||||
termination_thread_running = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !termination_thread_running {
|
||||
break;
|
||||
}
|
||||
sys.refresh_processes(sysinfo::ProcessesToUpdate::All, true);
|
||||
thread::sleep(Duration::from_millis(500));
|
||||
}
|
||||
|
||||
updater_process.wait().map_err(|e| e.to_string())?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn run_osu(folder: String) -> Result<(), String> {
|
||||
let osu_exe_path = PathBuf::from(folder).join("osu!.exe");
|
||||
#[cfg(windows)]
|
||||
const DETACHED_PROCESS: u32 = 0x00000008;
|
||||
#[cfg(windows)]
|
||||
const CREATE_NEW_PROCESS_GROUP: u32 = 0x00000200;
|
||||
|
||||
#[cfg(windows)]
|
||||
let mut game_process = Command::new(osu_exe_path)
|
||||
.creation_flags(DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP)
|
||||
.spawn()
|
||||
.map_err(|e| e.to_string())?;
|
||||
.creation_flags(DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP)
|
||||
.arg("-devserver")
|
||||
.arg("ez-pp.farm")
|
||||
.spawn()
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
#[cfg(not(windows))]
|
||||
let mut game_process = Command::new(osu_exe_path)
|
||||
.spawn()
|
||||
.map_err(|e| e.to_string())?;
|
||||
.arg("-devserver")
|
||||
.arg("ez-pp.farm")
|
||||
.spawn()
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
game_process.wait().map_err(|e| e.to_string())?;
|
||||
|
||||
|
@@ -4,9 +4,9 @@ use tauri::Manager;
|
||||
pub mod commands;
|
||||
pub mod utils;
|
||||
use crate::commands::{
|
||||
find_osu_installation, get_beatmapsets_count, get_hwid, get_osu_previous_release_stream,
|
||||
get_osu_release_stream, get_osu_version, get_skins_count, run_osu, run_osu_updater,
|
||||
set_osu_config_values, set_osu_user_config_values, valid_osu_folder,
|
||||
find_osu_installation, get_beatmapsets_count, get_hwid, get_osu_release_stream,
|
||||
get_osu_version, get_skins_count, run_osu, run_osu_updater, set_osu_config_values,
|
||||
set_osu_user_config_values, valid_osu_folder,
|
||||
};
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
@@ -32,7 +32,6 @@ pub fn run() {
|
||||
get_skins_count,
|
||||
get_osu_version,
|
||||
get_osu_release_stream,
|
||||
get_osu_previous_release_stream,
|
||||
set_osu_config_values,
|
||||
set_osu_user_config_values,
|
||||
run_osu_updater,
|
||||
|
Reference in New Issue
Block a user