Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove use of hard links to symlinks on macOS. #3137

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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