aboutsummaryrefslogtreecommitdiff
path: root/src-tauri/src/platform_specific
diff options
context:
space:
mode:
Diffstat (limited to 'src-tauri/src/platform_specific')
-rw-r--r--src-tauri/src/platform_specific/linux.rs62
1 files changed, 46 insertions, 16 deletions
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(())