Просмотр исходного кода

fix: Fix windows build when canonicalize returns an error

Robert Minsk 2 лет назад
Родитель
Сommit
c72840f3d2
1 измененных файлов с 1 добавлено и 1 удалено
  1. 1 1
      src/fs/feature/git.rs

+ 1 - 1
src/fs/feature/git.rs

@@ -332,7 +332,7 @@ fn reorient(path: &Path) -> PathBuf {
 
 
 #[cfg(windows)]
 #[cfg(windows)]
 fn reorient(path: &Path) -> PathBuf {
 fn reorient(path: &Path) -> PathBuf {
-    let unc_path = path.canonicalize().unwrap_or(path);
+    let unc_path = path.canonicalize().unwrap_or_else(|_| path.to_path_buf());
     // On Windows UNC path is returned. We need to strip the prefix for it to work.
     // On Windows UNC path is returned. We need to strip the prefix for it to work.
     let normal_path = unc_path.as_os_str().to_str().unwrap().trim_start_matches("\\\\?\\");
     let normal_path = unc_path.as_os_str().to_str().unwrap().trim_start_matches("\\\\?\\");
     PathBuf::from(normal_path)
     PathBuf::from(normal_path)