diff options
Diffstat (limited to 'src-tauri/src')
-rw-r--r-- | src-tauri/src/northstar/install.rs | 25 | ||||
-rw-r--r-- | src-tauri/src/northstar/mod.rs | 22 | ||||
-rw-r--r-- | src-tauri/src/platform_specific/linux.rs | 62 |
3 files changed, 77 insertions, 32 deletions
diff --git a/src-tauri/src/northstar/install.rs b/src-tauri/src/northstar/install.rs index e0653ddb..048d7596 100644 --- a/src-tauri/src/northstar/install.rs +++ b/src-tauri/src/northstar/install.rs @@ -293,7 +293,7 @@ pub async fn install_northstar( pub fn find_game_install_location() -> Result<GameInstall, String> { // Attempt parsing Steam library directly match steamlocate::SteamDir::locate() { - Some(mut steamdir) => { + Ok(steamdir) => { #[cfg(target_os = "linux")] { let snap_dir = match std::env::var("SNAP_USER_DATA") { @@ -305,25 +305,34 @@ pub fn find_game_install_location() -> Result<GameInstall, String> { .join("snap"), }; - if steamdir.path.starts_with(snap_dir) { + if steamdir.path().starts_with(snap_dir) { log::warn!("Found Steam installed via Snap, you may encounter issues"); } } - match steamdir.app(&thermite::TITANFALL2_STEAM_ID) { - Some(app) => { - // println!("{:#?}", app); + match steamdir.find_app(thermite::TITANFALL2_STEAM_ID) { + Ok(result) => { + let (app, library) = result.unwrap(); + let app_path = library + .path() + .join("steamapps") + .join("common") + .join(app.install_dir) + .into_os_string() + .into_string() + .unwrap(); + let game_install = GameInstall { - game_path: app.path.to_str().unwrap().to_string(), + game_path: app_path, profile: "R2Northstar".to_string(), install_type: InstallType::STEAM, }; return Ok(game_install); } - None => log::info!("Couldn't locate Titanfall2 Steam install"), + Err(err) => log::info!("Couldn't locate Titanfall2 Steam install. {}", err), } } - None => log::info!("Couldn't locate Steam on this computer!"), + Err(err) => log::info!("Couldn't locate Steam on this computer! {}", err), } // (On Windows only) try parsing Windows registry for Origin install path diff --git a/src-tauri/src/northstar/mod.rs b/src-tauri/src/northstar/mod.rs index 0b37c3f6..4b16f701 100644 --- a/src-tauri/src/northstar/mod.rs +++ b/src-tauri/src/northstar/mod.rs @@ -235,19 +235,25 @@ pub fn launch_northstar_steam(game_install: GameInstall) -> Result<String, Strin } match steamlocate::SteamDir::locate() { - Some(mut steamdir) => { + Ok(steamdir) => { if get_host_os() != "windows" { - match steamdir.compat_tool(&thermite::TITANFALL2_STEAM_ID) { - Some(_) => {} - None => { - return Err( - "Titanfall2 was not configured to use a compatibility tool".to_string() - ); + match steamdir.compat_tool_mapping() { + Ok(map) => match map.get(&thermite::TITANFALL2_STEAM_ID) { + Some(_) => {} + None => { + return Err( + "Titanfall2 was not configured to use a compatibility tool" + .to_string(), + ); + } + }, + Err(_) => { + return Err("Could not get compatibility tool mapping".to_string()); } } } } - None => { + Err(_) => { return Err("Couldn't access Titanfall2 directory".to_string()); } } diff --git a/src-tauri/src/platform_specific/linux.rs b/src-tauri/src/platform_specific/linux.rs index 4a901cb8..fcac5b67 100644 --- a/src-tauri/src/platform_specific/linux.rs +++ b/src-tauri/src/platform_specific/linux.rs @@ -1,49 +1,79 @@ // Linux specific code -fn get_proton_dir() -> Option<String> { - let steam_dir = steamlocate::SteamDir::locate()?; - let compat_dir = format!("{}/compatibilitytools.d", steam_dir.path.display()); - - Some(compat_dir) +fn get_proton_dir() -> Result<String, String> { + let steam_dir = match steamlocate::SteamDir::locate() { + Ok(result) => result, + Err(_) => return Err("Unable to find Steam directory".to_string()), + }; + let compat_dir = format!("{}/compatibilitytools.d", steam_dir.path().display()); + + Ok(compat_dir) } /// Downloads and installs NS proton /// Assumes Steam install -pub fn install_ns_proton() -> Result<(), thermite::prelude::ThermiteError> { +pub fn install_ns_proton() -> Result<(), String> { // Get latest NorthstarProton release - let latest = thermite::core::latest_release()?; + let latest = match thermite::core::latest_release() { + Ok(result) => result, + Err(_) => return Err("Failed to fetch latest NorthstarProton release".to_string()), + }; let temp_dir = std::env::temp_dir(); let path = format!("{}/nsproton-{}.tar.gz", temp_dir.display(), latest); - let archive = std::fs::File::create(path.clone())?; + let archive = match std::fs::File::create(path.clone()) { + Ok(result) => result, + Err(_) => return Err("Failed to allocate NorthstarProton archive on disk".to_string()), + }; // Download the latest Proton release log::info!("Downloading NorthstarProton to {}", path); - thermite::core::download_ns_proton(latest, archive)?; + match thermite::core::download_ns_proton(latest, archive) { + Ok(_) => {} + Err(_) => return Err("Failed to download NorthstarProton".to_string()), + } + log::info!("Finished Download"); - let compat_dir = get_proton_dir().unwrap(); - std::fs::create_dir_all(compat_dir.clone())?; + let compat_dir = get_proton_dir()?; - let finished = std::fs::File::open(path.clone())?; + match std::fs::create_dir_all(compat_dir.clone()) { + Ok(_) => {} + Err(_) => return Err("Failed to create compatibilitytools directory".to_string()), + } + + let finished = match std::fs::File::open(path.clone()) { + Ok(result) => result, + Err(_) => return Err("Failed to open NorthstarProton archive".to_string()), + }; // Extract to Proton dir log::info!("Installing NorthstarProton to {}", compat_dir); - thermite::core::install_ns_proton(&finished, compat_dir)?; + match thermite::core::install_ns_proton(&finished, compat_dir) { + Ok(_) => {} + Err(_) => return Err("Failed to create install NorthstarProton".to_string()), + } log::info!("Finished Installation"); drop(finished); - std::fs::remove_file(path)?; + // We installed NSProton, lets ignore this if it fails + let _ = std::fs::remove_file(path); Ok(()) } /// Remove NS Proton pub fn uninstall_ns_proton() -> Result<(), String> { - let compat_dir = get_proton_dir().unwrap(); + let compat_dir = get_proton_dir()?; let pattern = format!("{}/NorthstarProton*", compat_dir); for e in glob::glob(&pattern).expect("Failed to read glob pattern") { - std::fs::remove_dir_all(e.unwrap()).unwrap(); + match e { + Ok(path) => match std::fs::remove_dir_all(path.clone()) { + Ok(_) => {} + Err(_) => return Err(format!("Failed to remove {}", path.display())), + }, + Err(e) => return Err(format!("Found unprocessable entry {}", e)), + } } Ok(()) |