Skip to content

Commit f561231

Browse files
committed
perf: handle Windows Store review edge cases (PR #418)
1 parent 5bd6e66 commit f561231

File tree

1 file changed

+18
-4
lines changed
  • crates/pet-windows-store/src

1 file changed

+18
-4
lines changed

crates/pet-windows-store/src/lib.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ use std::path::{Path, PathBuf};
2121
use std::sync::{Arc, RwLock};
2222

2323
#[derive(Clone, Debug)]
24+
#[cfg_attr(not(any(windows, test)), allow(dead_code))]
2425
struct CachedStoreEnvironment {
25-
#[allow(dead_code)]
2626
environment: PythonEnvironment,
27-
#[allow(dead_code)]
2827
normalized_symlinks: Vec<PathBuf>,
2928
}
3029

@@ -50,8 +49,10 @@ impl CachedStoreEnvironment {
5049
fn normalize_for_comparison(path: &Path) -> PathBuf {
5150
let normalized = norm_case(path);
5251
let path_str = normalized.to_string_lossy();
53-
if path_str.starts_with(r"\\?\") {
54-
PathBuf::from(path_str.trim_start_matches(r"\\?\"))
52+
if let Some(unc_path) = path_str.strip_prefix(r"\\?\UNC\") {
53+
PathBuf::from(format!(r"\\{unc_path}"))
54+
} else if let Some(path_without_prefix) = path_str.strip_prefix(r"\\?\") {
55+
PathBuf::from(path_without_prefix)
5556
} else {
5657
normalized
5758
}
@@ -257,6 +258,19 @@ mod tests {
257258
);
258259
}
259260

261+
#[test]
262+
fn cached_store_environment_normalizes_extended_unc_symlinks() {
263+
let cached = CachedStoreEnvironment::from_environment(PythonEnvironment {
264+
symlinks: Some(vec![PathBuf::from(r"\\?\UNC\server\share\python.exe")]),
265+
..Default::default()
266+
});
267+
268+
assert_eq!(
269+
cached.normalized_symlinks,
270+
vec![PathBuf::from(r"\\server\share\python.exe")]
271+
);
272+
}
273+
260274
#[cfg(windows)]
261275
#[test]
262276
fn try_from_matches_cached_normalized_symlink() {

0 commit comments

Comments
 (0)