Skip to content

Commit

Permalink
Preserve symlinks when installing
Browse files Browse the repository at this point in the history
The lldb-preview component includes symlinks.  Currently, rustup
changes these to be regular files while installing.  This then causes
the resulting lldb to load liblldb twice, which causes a crash at
startup, because command line options are registered twice.  This
changes rustup to preserve symlinks when installing.
  • Loading branch information
tromey committed Sep 14, 2018
1 parent ea9259c commit c4a6a6c
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/rustup-utils/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,24 @@ pub fn copy_dir(src: &Path, dest: &Path, notify_handler: &Fn(Notification)) -> R
}

pub fn copy_file(src: &Path, dest: &Path) -> Result<()> {
fs::copy(src, dest)
.chain_err(|| ErrorKind::CopyingFile {
src: PathBuf::from(src),
dest: PathBuf::from(dest),
})
.map(|_| ())
let metadata = fs::symlink_metadata(src).chain_err(|| ErrorKind::ReadingFile {
name: "metadata for",
path: PathBuf::from(src),
})?;
if metadata.file_type().is_symlink() {
let link = fs::read_link(src).chain_err(|| ErrorKind::ReadingFile {
name: "link contents for",
path: PathBuf::from(src),
})?;
symlink_file(&link, dest).map(|_| ())
} else {
fs::copy(src, dest)
.chain_err(|| ErrorKind::CopyingFile {
src: PathBuf::from(src),
dest: PathBuf::from(dest),
})
.map(|_| ())
}
}

pub fn remove_dir(
Expand Down

0 comments on commit c4a6a6c

Please sign in to comment.