Skip to content

Commit

Permalink
Panic in case rewriting dependency paths yields a non-UTF8 sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
hdoordt committed Nov 4, 2024
1 parent 1aa5a8a commit 8b8293c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ fn rewrite_dep_paths_as_absolute<'a, P: AsRef<std::path::Path>>(
.as_ref()
.join(path)
.canonicalize()
.unwrap()
.to_string_lossy()
.expect("Error rewriting dependency path as absolute: unable to canonicalize paths.")
.to_str()
.expect("Error rewriting dependency path as absolute: absolute path is not UTF-8.")
.to_string()
})
}
Expand All @@ -82,8 +83,11 @@ fn rewrite_dep_path_as_relative<P: AsRef<std::path::Path>>(dep: &mut Dependency,
if let Dependency::Detailed(detail) = dep {
detail.path = detail.path.as_mut().map(|path| {
pathdiff::diff_paths(path, parent.as_ref())
.unwrap()
.to_string_lossy()
.expect(
"Error rewriting dependency path as relative: unable to determing path diff.",
)
.to_str()
.expect("Error rewriting dependency path as relative: path diff is not UTF-8.")
.to_string()
})
}
Expand Down

0 comments on commit 8b8293c

Please sign in to comment.