Skip to content

Commit

Permalink
Panic in case rewriting dependency paths as absoluteyields a non-UTF8…
Browse files Browse the repository at this point in the history
… sequence
  • Loading branch information
hdoordt committed Nov 5, 2024
1 parent c5b5bcd commit 4287c0e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ fn rewrite_dep_paths_as_absolute<'a, P: AsRef<std::path::Path>>(
.join(path)
.canonicalize()
.unwrap()
.to_string_lossy()
.to_str()
.expect("Canonicalized absolute path contained non-UTF-8 segments.")
.to_string()
})
}
Expand All @@ -81,7 +82,7 @@ fn rewrite_dep_paths_as_absolute<'a, P: AsRef<std::path::Path>>(
fn rewrite_dep_path_as_relative<P: AsRef<std::path::Path>>(dep: &mut Dependency, parent: P) {
if let Dependency::Detailed(detail) = dep {
detail.path = detail.path.as_mut().map(|path| {
pathdiff::diff_paths(path, parent.as_ref())
pathdiff::diff_paths(path, parent.as_ref().canonicalize().unwrap())
.expect(
"Error rewriting dependency path as relative: unable to determine path diff.",
)
Expand Down

0 comments on commit 4287c0e

Please sign in to comment.