From 24ca626e2bd0a7b35d4e0421ec3722fa710c62c4 Mon Sep 17 00:00:00 2001 From: Jan Date: Sun, 14 Apr 2024 02:23:11 +0200 Subject: fix: Change Proton detection for new GE base (#892) Update Proton detection logic for newer versions of NorthstarProton which are based on newer ProtonGE versions. --- src-tauri/src/platform_specific/linux.rs | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) (limited to 'src-tauri/src/platform_specific') diff --git a/src-tauri/src/platform_specific/linux.rs b/src-tauri/src/platform_specific/linux.rs index 706a4d22..756fced1 100644 --- a/src-tauri/src/platform_specific/linux.rs +++ b/src-tauri/src/platform_specific/linux.rs @@ -26,7 +26,7 @@ pub fn linux_checks_librs() -> Result<(), String> { fn get_proton_dir() -> Option { let steam_dir = steamlocate::SteamDir::locate()?; - let compat_dir = format!("{}/compatibilitytools.d/", steam_dir.path.display()); + let compat_dir = format!("{}/compatibilitytools.d", steam_dir.path.display()); Some(compat_dir) } @@ -65,7 +65,7 @@ pub fn install_ns_proton() -> Result<(), thermite::prelude::ThermiteError> { /// Remove NS Proton pub fn uninstall_ns_proton() -> Result<(), String> { let compat_dir = get_proton_dir().unwrap(); - let pattern = format!("{}/NorthstarProton-*", compat_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(); } @@ -76,27 +76,19 @@ pub fn uninstall_ns_proton() -> Result<(), String> { /// Get the latest installed NS Proton version pub fn get_local_ns_proton_version() -> Result { let compat_dir = get_proton_dir().unwrap(); - let ns_prefix = "NorthstarProton-"; - let pattern = format!("{}/{}*/version", compat_dir, ns_prefix); + let pattern = format!("{}/NorthstarProton*/version", compat_dir); - let mut version: String = "".to_string(); - - for e in glob::glob(&pattern).expect("Failed to read glob pattern") { + if let Some(e) = glob::glob(&pattern) + .expect("Failed to read glob pattern") + .next() + { let version_content = std::fs::read_to_string(e.unwrap()).unwrap(); - let version_string = version_content.split(' ').nth(1).unwrap(); - - if version_string.starts_with(ns_prefix) { - version = version_string[ns_prefix.len()..version_string.len() - 1] - .to_string() - .clone(); - } - } + let version = version_content.split(' ').nth(1).unwrap().to_string(); - if version.is_empty() { - return Err("Northstar Proton is not installed".to_string()); + return Ok(version); } - Ok(version) + Err("Northstar Proton is not installed".to_string()) } pub fn check_glibc_v() -> f32 { -- cgit v1.2.3