chore: Apply stashed changes

This commit is contained in:
quexeky
2025-01-20 18:22:24 +11:00
parent 4fc0855ba1
commit e0ea8c9a57
3 changed files with 35 additions and 16 deletions

View File

@ -60,7 +60,9 @@ pub struct GameVersion {
pub version_index: usize,
pub version_name: String,
pub launch_command: String,
pub launch_args: Vec<String>,
pub setup_command: String,
pub setup_args: Vec<String>,
pub platform: Platform,
}

View File

@ -72,12 +72,22 @@ pub struct StatsUpdateEvent {
#[derive(serde::Deserialize, serde::Serialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct GameVersionOption {
version_index: usize,
game_id: String,
version_name: String,
platform: Platform,
setup_command: String,
launch_command: String,
launch_args: Vec<String>,
setup_command: String,
setup_args: Vec<String>,
only_setup: bool,
version_index: usize,
delta: bool,
umu_id_override: Option<String>,
// total_size: usize,
}

View File

@ -70,8 +70,8 @@ impl ProcessManager<'_> {
// spaces and it's arguments.
// 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
fn process_command(&self, install_dir: &String, raw_command: String) -> (PathBuf, Vec<String>) {
let root = raw_command;
fn process_command(&self, install_dir: &String, command: Vec<String>) -> (PathBuf, Vec<String>) {
let root = &command[0];
let install_dir = Path::new(install_dir);
let absolute_exe = install_dir.join(root);
@ -190,23 +190,22 @@ impl ProcessManager<'_> {
.get(&game_id)
.ok_or(ProcessError::NotInstalled)?;
let status_metadata: Option<(&String, &String)> = match game_status {
let (version_name, install_dir) = match game_status {
GameDownloadStatus::Installed {
version_name,
install_dir,
<<<<<<< Updated upstream
} => Some((version_name, install_dir)),
=======
} => (version_name, install_dir),
>>>>>>> Stashed changes
GameDownloadStatus::SetupRequired {
version_name,
install_dir,
} => Some((version_name, install_dir)),
_ => None,
} => (version_name, install_dir),
_ => 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
.applications
@ -216,19 +215,27 @@ impl ProcessManager<'_> {
.get(version_name)
.ok_or(ProcessError::InvalidVersion)?;
let raw_command: String = match game_status {
let mut command: Vec<String> = Vec::new();
match game_status {
GameDownloadStatus::Installed {
version_name: _,
install_dir: _,
} => game_version.launch_command.clone(),
} => {
command.extend_one(game_version.launch_command);
command.extend(game_version.launch_args);
},
GameDownloadStatus::SetupRequired {
version_name: _,
install_dir: _,
} => game_version.setup_command.clone(),
} => {
command.extend_one(game_version.setup_command);
command.extend(game_version.setup_args);
},
_ => 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();