refactor(link): propagate canonicalization errors

Signed-off-by: Christina Sørensen <christina@cafkafk.com>
This commit is contained in:
Christina Sørensen 2023-10-17 07:04:27 +02:00
parent 41334cdaf0
commit a1a52b10f3
Signed by: cafkafk
GPG key ID: 26C542FD97F965CE

View file

@ -172,10 +172,7 @@ impl From<std::io::Error> for LinkError {
fn handle_file_exists(selff: &Link, tx_path: &Path, rx_path: &Path) -> Result<bool, LinkError> {
match rx_path.read_link() {
Ok(file)
if file.canonicalize().expect("failed to canonicalize file")
== tx_path.canonicalize().expect("failed to canonicalize path") =>
{
Ok(file) if file.canonicalize()? == tx_path.canonicalize()? => {
Err(LinkError::AlreadyLinked(
tx_path.to_string_lossy().to_string(),
rx_path.to_string_lossy().to_string(),