chore: Apply stashed changes

This commit is contained in:
quexeky
2025-01-20 18:22:24 +11:00
parent 48a7463040
commit 9831d96300
3 changed files with 35 additions and 16 deletions
+2
View File
@@ -60,7 +60,9 @@ pub struct GameVersion {
pub version_index: usize, pub version_index: usize,
pub version_name: String, pub version_name: String,
pub launch_command: String, pub launch_command: String,
pub launch_args: Vec<String>,
pub setup_command: String, pub setup_command: String,
pub setup_args: Vec<String>,
pub platform: Platform, pub platform: Platform,
} }
+12 -2
View File
@@ -72,12 +72,22 @@ pub struct StatsUpdateEvent {
#[derive(serde::Deserialize, serde::Serialize, Debug)] #[derive(serde::Deserialize, serde::Serialize, Debug)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct GameVersionOption { pub struct GameVersionOption {
version_index: usize, game_id: String,
version_name: String, version_name: String,
platform: Platform, platform: Platform,
setup_command: String,
launch_command: String, launch_command: String,
launch_args: Vec<String>,
setup_command: String,
setup_args: Vec<String>,
only_setup: bool,
version_index: usize,
delta: bool, delta: bool,
umu_id_override: Option<String>, umu_id_override: Option<String>,
// total_size: usize, // total_size: usize,
} }
@@ -70,8 +70,8 @@ impl ProcessManager<'_> {
// spaces and it's arguments. // spaces and it's arguments.
// I think if we just join the install_dir to whatever the user provides us, we'll be alright // I think if we just join the install_dir to whatever the user provides us, we'll be alright
// In future, we should have a separate field for executable name and it's arguments // In future, we should have a separate field for executable name and it's arguments
fn process_command(&self, install_dir: &String, raw_command: String) -> (PathBuf, Vec<String>) { fn process_command(&self, install_dir: &String, command: Vec<String>) -> (PathBuf, Vec<String>) {
let root = raw_command; let root = &command[0];
let install_dir = Path::new(install_dir); let install_dir = Path::new(install_dir);
let absolute_exe = install_dir.join(root); let absolute_exe = install_dir.join(root);
@@ -190,23 +190,22 @@ impl ProcessManager<'_> {
.get(&game_id) .get(&game_id)
.ok_or(ProcessError::NotInstalled)?; .ok_or(ProcessError::NotInstalled)?;
let status_metadata: Option<(&String, &String)> = match game_status { let (version_name, install_dir) = match game_status {
GameDownloadStatus::Installed { GameDownloadStatus::Installed {
version_name, version_name,
install_dir, install_dir,
<<<<<<< Updated upstream
} => Some((version_name, install_dir)), } => Some((version_name, install_dir)),
=======
} => (version_name, install_dir),
>>>>>>> Stashed changes
GameDownloadStatus::SetupRequired { GameDownloadStatus::SetupRequired {
version_name, version_name,
install_dir, install_dir,
} => Some((version_name, install_dir)), } => (version_name, install_dir),
_ => None, _ => return Err(ProcessError::NotDownloaded),
}; };
if status_metadata.is_none() {
return Err(ProcessError::NotDownloaded);
}
let (version_name, install_dir) = status_metadata.unwrap();
let game_version = db_lock let game_version = db_lock
.applications .applications
@@ -216,19 +215,27 @@ impl ProcessManager<'_> {
.get(version_name) .get(version_name)
.ok_or(ProcessError::InvalidVersion)?; .ok_or(ProcessError::InvalidVersion)?;
let raw_command: String = match game_status { let mut command: Vec<String> = Vec::new();
match game_status {
GameDownloadStatus::Installed { GameDownloadStatus::Installed {
version_name: _, version_name: _,
install_dir: _, install_dir: _,
} => game_version.launch_command.clone(), } => {
command.extend_one(game_version.launch_command);
command.extend(game_version.launch_args);
},
GameDownloadStatus::SetupRequired { GameDownloadStatus::SetupRequired {
version_name: _, version_name: _,
install_dir: _, install_dir: _,
} => game_version.setup_command.clone(), } => {
command.extend_one(game_version.setup_command);
command.extend(game_version.setup_args);
},
_ => panic!("unreachable code"), _ => panic!("unreachable code"),
}; };
let (command, args) = self.process_command(install_dir, raw_command); let (command, args) = self.process_command(install_dir, command);
let target_current_dir = command.parent().unwrap().to_str().unwrap(); let target_current_dir = command.parent().unwrap().to_str().unwrap();