Skip to content

Commit

Permalink
cargo-install: move binaries from the build dir if possible
Browse files Browse the repository at this point in the history
Try moving the binaries (and fall back to copying) if the build
directory is a temporary one (source isn't a local path).
  • Loading branch information
gkoz committed Apr 30, 2016
1 parent 9ea1f2a commit 9f0fa24
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/cargo/ops/cargo_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ pub fn install(root: Option<&str>,
let staging_dir = try!(TempDir::new_in(&dst, "cargo-install"));
for &(bin, src) in binaries.iter() {
let dst = staging_dir.path().join(bin);
// Try to move if `target_dir` is transient.
if !source_id.is_path() {
if fs::rename(src, &dst).is_ok() {
continue
}
}
try!(fs::copy(src, &dst).chain_error(|| {
human(format!("failed to copy `{}` to `{}`", src.display(),
dst.display()))
Expand Down

0 comments on commit 9f0fa24

Please sign in to comment.