From 00db2a51c2e108c3af48952a07addf0c64d3013b Mon Sep 17 00:00:00 2001 From: daimond113 <72147841+daimond113@users.noreply.github.com> Date: Thu, 29 Aug 2024 00:24:52 +0200 Subject: [PATCH] fix: parse versions on non windows platforms correctly --- src/cli/version.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/cli/version.rs b/src/cli/version.rs index 52ba510..fdd2f83 100644 --- a/src/cli/version.rs +++ b/src/cli/version.rs @@ -206,7 +206,24 @@ pub fn max_installed_version() -> anyhow::Result { .context("failed to read versions directory")? .collect::, _>>()? .into_iter() - .map(|entry| Version::parse(entry.path().file_stem().unwrap().to_str().unwrap()).unwrap()) + .map(|entry| { + #[cfg(not(windows))] + let name = entry + .path() + .file_name() + .unwrap() + .to_string_lossy() + .to_string(); + #[cfg(windows)] + let name = entry + .path() + .file_stem() + .unwrap() + .to_string_lossy() + .to_string(); + + Version::parse(&name).unwrap() + }) .max() .filter(|v| v >= ¤t_version()) .unwrap_or_else(current_version);