From 21d59b5e05f3ba249f04f94b7c6c0301934d6b6a Mon Sep 17 00:00:00 2001 From: TheGB0077 <39922116+TheGB0077@users.noreply.github.com> Date: Mon, 3 Jun 2024 14:28:04 -0300 Subject: [PATCH] logic simplified --- crates/gitbutler-tauri/src/menu.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/gitbutler-tauri/src/menu.rs b/crates/gitbutler-tauri/src/menu.rs index c415e15ca..64689f4aa 100644 --- a/crates/gitbutler-tauri/src/menu.rs +++ b/crates/gitbutler-tauri/src/menu.rs @@ -48,16 +48,16 @@ pub fn resolve_vscode_variant() -> &'static str { } fn check_if_installed(executable_name: &str) -> bool { - let paths = match env::var_os("PATH") { - Some(path) => env::split_paths(&path).collect::>(), - None => vec![], - }; - - paths.into_iter().any(|mut path| { - path.push(executable_name); - //println!("{}", path.to_string_lossy()); - fs::metadata(path).is_ok() - }) + match env::var_os("PATH") { + Some(env_path) => env::split_paths(&env_path) + .filter_map(|mut path| { + path.push(executable_name); + fs::metadata(path).ok() + }) + .next() + .is_some(), + None => false, + } } pub fn build(_package_info: &PackageInfo) -> Menu {