@@ -21,10 +21,9 @@ use std::path::{Path, PathBuf};
2121use std:: sync:: { Arc , RwLock } ;
2222
2323#[ derive( Clone , Debug ) ]
24+ #[ cfg_attr( not( any( windows, test) ) , allow( dead_code) ) ]
2425struct 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 {
5049fn 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