Direct the symlink the right way in symlink info!(), point at actual destination

This commit is contained in:
наб 2022-03-13 16:29:15 +01:00
parent 5b4909f9eb
commit f76791b9b9
No known key found for this signature in database
GPG key ID: BCFD0B018D2658F1

View file

@ -1,6 +1,4 @@
use std::path::PathBuf; use std::path::{PathBuf, Path};
#[cfg(target_family = "unix")]
use std::path::Path;
use cargo_toml::Product; use cargo_toml::Product;
use log::debug; use log::debug;
@ -72,8 +70,8 @@ impl BinFile {
format!( format!(
"{} ({} -> {})", "{} ({} -> {})",
self.base_name, 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)?; std::fs::remove_file(&self.link)?;
} }
#[cfg(target_family = "unix")] let dest = self.link_dest();
let dest = &Path::new(self.dest.file_name().unwrap());
#[cfg(target_family = "windows")]
let dest = &self.dest;
debug!( debug!(
"Create link '{}' pointing to '{}'", "Create link '{}' pointing to '{}'",
self.link.display(), self.link.display(),
@ -120,6 +115,13 @@ impl BinFile {
Ok(()) 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 /// Data required to get bin paths