wip: osu! updating
This commit is contained in:
parent
9182c2c994
commit
75380038ad
@ -224,11 +224,14 @@ pub fn set_osu_config_value(
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn run_osu_updater(osu_path: String) -> Result<(), String> {
|
||||
let mut updater_process = Command::new(osu_path.clone())
|
||||
.arg("-repair")
|
||||
.spawn()
|
||||
.map_err(|e| e.to_string())?;
|
||||
pub fn run_osu_updater(folder: String) -> Result<(), String> {
|
||||
let osu_exe_path = PathBuf::from(folder).join("osu!.exe");
|
||||
let mut updater_process = Command::new(osu_exe_path)
|
||||
.arg("-repair")
|
||||
.spawn()
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
|
||||
|
||||
thread::sleep(Duration::from_millis(500));
|
||||
|
||||
@ -243,8 +246,15 @@ pub fn run_osu_updater(osu_path: String) -> Result<(), String> {
|
||||
let process_id = process.pid();
|
||||
let window_title = get_window_title_by_pid(process_id);
|
||||
|
||||
println!("updater_process id: {}", updater_process.id());
|
||||
println!("process_id: {}", process_id.as_u32());
|
||||
|
||||
println!("found osu!.exe process with window title: {}", window_title);
|
||||
|
||||
if !window_title.is_empty() {
|
||||
println!("Killing osu!.exe process");
|
||||
if let Ok(_) = process.kill_and_wait() {
|
||||
println!("osu!.exe process killed");
|
||||
termination_thread_running = false;
|
||||
break;
|
||||
}
|
||||
|
@ -4,10 +4,7 @@ use std::os::windows::ffi::OsStringExt;
|
||||
use std::path::Path;
|
||||
use std::ptr;
|
||||
use sysinfo::Pid;
|
||||
use winapi::{
|
||||
shared::minwindef::LPARAM,
|
||||
um::winuser::{FindWindowW, GetWindowTextW, GetWindowThreadProcessId},
|
||||
};
|
||||
use winapi::um::winuser::{FindWindowW, GetWindowTextW, GetWindowThreadProcessId};
|
||||
|
||||
pub fn check_folder_completeness<P: AsRef<Path>>(folder_path: P, required_files: &[&str]) -> f32 {
|
||||
let mut found = 0;
|
||||
@ -27,12 +24,10 @@ pub fn check_folder_completeness<P: AsRef<Path>>(folder_path: P, required_files:
|
||||
pub fn get_osu_user_config<P: AsRef<Path>>(
|
||||
osu_folder_path: P,
|
||||
) -> Option<std::collections::HashMap<String, String>> {
|
||||
// Ensure the osu! folder path is valid
|
||||
if !osu_folder_path.as_ref().exists() {
|
||||
return None;
|
||||
}
|
||||
|
||||
// get the osu!{username}.cfg file from the osu! folder
|
||||
let current_user = std::env::var("USERNAME").unwrap_or_else(|_| "Admin".to_string());
|
||||
let osu_config_path = osu_folder_path
|
||||
.as_ref()
|
||||
@ -41,7 +36,6 @@ pub fn get_osu_user_config<P: AsRef<Path>>(
|
||||
return None;
|
||||
}
|
||||
|
||||
// read the osu config and return it as a map, key and value are separated by ' = '
|
||||
let mut config_map = std::collections::HashMap::new();
|
||||
if let Ok(contents) = std::fs::read_to_string(osu_config_path) {
|
||||
for line in contents.lines() {
|
||||
@ -97,18 +91,15 @@ pub fn set_osu_user_config_value(
|
||||
pub fn get_osu_config<P: AsRef<Path>>(
|
||||
osu_folder_path: P,
|
||||
) -> Option<std::collections::HashMap<String, String>> {
|
||||
// Ensure the osu! folder path is valid
|
||||
if !osu_folder_path.as_ref().exists() {
|
||||
return None;
|
||||
}
|
||||
|
||||
// get the osu!.cfg file from the osu! folder
|
||||
let osu_config_path = osu_folder_path.as_ref().join("osu!.cfg");
|
||||
if !osu_config_path.exists() {
|
||||
return None;
|
||||
}
|
||||
|
||||
// read the osu config and return it as a map, key and value are separated by ' = '
|
||||
let mut config_map = std::collections::HashMap::new();
|
||||
if let Ok(contents) = std::fs::read_to_string(osu_config_path) {
|
||||
for line in contents.lines() {
|
||||
|
@ -58,7 +58,9 @@ export const releaseStreamToReadable = (releaseStream: string) => {
|
||||
|
||||
export const compareBuildNumbers = (current: string, target: string): number => {
|
||||
const parse = (version: string): [number, number] => {
|
||||
const cleaned = version.split(/[^0-9.]/)[0];
|
||||
const cleaned = version.startsWith('b')
|
||||
? version.slice(1).split(/[^0-9.]/)[0]
|
||||
: version.split(/[^0-9.]/)[0];
|
||||
|
||||
const [baseStr, hotfixStr] = cleaned.split('.');
|
||||
const base = parseInt(baseStr, 10);
|
||||
|
@ -145,7 +145,6 @@
|
||||
}
|
||||
|
||||
const versions = compareBuildNumbers($osuBuild, streamInfo);
|
||||
|
||||
if (versions > 0) {
|
||||
launchInfo = 'Update found!';
|
||||
await new Promise((res) => setTimeout(res, 1500));
|
||||
@ -154,7 +153,8 @@
|
||||
} else {
|
||||
launchInfo = 'You are up to date!';
|
||||
}
|
||||
} catch {
|
||||
} catch(err) {
|
||||
console.log(err);
|
||||
toast.error('Hmmm...', {
|
||||
description: 'Failed to check for updates.',
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user