From f76791b9b93c65cd77fa08975813197ac80026bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sun, 13 Mar 2022 16:29:15 +0100 Subject: [PATCH] Direct the symlink the right way in symlink info!(), point at actual destination --- src/bins.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/bins.rs b/src/bins.rs index beb74587..ce51dffe 100644 --- a/src/bins.rs +++ b/src/bins.rs @@ -1,6 +1,4 @@ -use std::path::PathBuf; -#[cfg(target_family = "unix")] -use std::path::Path; +use std::path::{PathBuf, Path}; use cargo_toml::Product; use log::debug; @@ -72,8 +70,8 @@ impl BinFile { format!( "{} ({} -> {})", self.base_name, - self.dest.display(), - self.link.display() + self.link.display(), + self.link_dest().display() ) } @@ -104,10 +102,7 @@ impl BinFile { std::fs::remove_file(&self.link)?; } - #[cfg(target_family = "unix")] - let dest = &Path::new(self.dest.file_name().unwrap()); - #[cfg(target_family = "windows")] - let dest = &self.dest; + let dest = self.link_dest(); debug!( "Create link '{}' pointing to '{}'", self.link.display(), @@ -120,6 +115,13 @@ impl BinFile { Ok(()) } + + fn link_dest(&self) -> &Path { + #[cfg(target_family = "unix")] + { Path::new(self.dest.file_name().unwrap()) } + #[cfg(target_family = "windows")] + { &self.dest } + } } /// Data required to get bin paths