]> git.lizzy.rs Git - rust.git/commitdiff
rustbuild: Fix a distribution bug with rustdoc
authorAlex Crichton <alex@alexcrichton.com>
Mon, 11 Sep 2017 18:01:48 +0000 (11:01 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Mon, 11 Sep 2017 18:01:48 +0000 (11:01 -0700)
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

src/bootstrap/dist.rs

index e18850b08b1670db95e9c43bd8b3f18300dd6691..8e11e1b0580e9d98f62d91332fa7f998278c9409 100644 (file)
@@ -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));