Skip to content

Commit

Permalink
Remove use of hardlinks to symlinks on macOS.
Browse files Browse the repository at this point in the history
Fixes #3136.
  • Loading branch information
brotskydotcom committed Jan 7, 2023
1 parent e0ffef9 commit 6c34b71
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/utils/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,15 @@ where
}

pub(crate) fn hard_or_symlink_file(src: &Path, dest: &Path) -> Result<()> {
if hardlink_file(src, dest).is_err() {
// Some mac filesystems can do hardlinks to symlinks, some can't.
// See rust-lang/rustup#3136 for why it's better never to use them.
#[cfg(target_os = "macos")]
let force_symlink = fs::symlink_metadata(src)
.map(|m| m.file_type().is_symlink())
.unwrap_or(false);
#[cfg(not(target_os = "macos"))]
let force_symlink = false;
if force_symlink || hardlink_file(src, dest).is_err() {
symlink_file(src, dest)?;
}
Ok(())
Expand Down

0 comments on commit 6c34b71

Please sign in to comment.