Skip to content

Commit

Permalink
Merge pull request #3137 from brotskydotcom/mac-no-hardlinks-to-symlinks
Browse files Browse the repository at this point in the history
Remove use of hard links to symlinks on macOS.
  • Loading branch information
rbtcollins authored Feb 23, 2023
2 parents f58e8c3 + be662a9 commit 5151d90
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 5151d90

Please sign in to comment.