Skip to content

Commit

Permalink
Merge pull request #177 from axodotdev/fix_canonicalizing_dead_path
Browse files Browse the repository at this point in the history
fix: handle canonicalizing dead path
  • Loading branch information
mistydemeo authored Sep 11, 2024
2 parents a548d60 + 3f0428e commit 2412d72
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion axoupdater/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,16 @@ impl AxoUpdater {
/// Returns a normalized version of install_prefix_root, for comparison
fn install_prefix_root_normalized(&self) -> AxoupdateResult<Utf8PathBuf> {
let raw_root = self.install_prefix_root()?;
let normalized = Utf8PathBuf::from_path_buf(raw_root.canonicalize()?)
// The canonicalize path could fail if the path doesn't exist anymore;
// catch that specific error here and return the original path.
// (We want to leave the UTF8 conversion to the next step so we handle
// those errors separately.)
let canonicalized = if let Ok(path) = raw_root.canonicalize() {
path
} else {
raw_root.into_std_path_buf()
};
let normalized = Utf8PathBuf::from_path_buf(canonicalized)
.map_err(|path| AxoupdateError::CaminoConversionFailed { path })?;
Ok(normalized)
}
Expand Down

0 comments on commit 2412d72

Please sign in to comment.