From: Alex Crichton Date: Mon, 11 Sep 2017 18:01:48 +0000 (-0700) Subject: rustbuild: Fix a distribution bug with rustdoc X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=eb26d5b7c928646983c53bcbd33ce578acbf238f;p=rust.git rustbuild: Fix a distribution bug with rustdoc Apparently `File::create` was called when there was an existing hard link or the like, causing an existing file to get accidentally truncated! Closes #44487 --- diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index e18850b08b1..8e11e1b0580 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -900,6 +900,7 @@ fn run(self, builder: &Builder) -> PathBuf { fn install(src: &Path, dstdir: &Path, perms: u32) { let dst = dstdir.join(src.file_name().unwrap()); t!(fs::create_dir_all(dstdir)); + drop(fs::remove_file(&dst)); { let mut s = t!(fs::File::open(&src)); let mut d = t!(fs::File::create(&dst));