Skip to content

Commit 1af6b32

Browse files
committed
Retry deleting dst a number of times
1 parent 1a19627 commit 1af6b32

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

src/bootstrap/src/lib.rs

+12-19
Original file line numberDiff line numberDiff line change
@@ -1676,7 +1676,7 @@ impl Build {
16761676
if src == dst {
16771677
return;
16781678
}
1679-
let _ = fs::remove_file(dst);
1679+
let _ = rety(60, || fs::remove_file(dst));
16801680
let metadata = t!(src.symlink_metadata(), format!("src = {}", src.display()));
16811681
let mut src = src.to_path_buf();
16821682
if metadata.file_type().is_symlink() {
@@ -1688,25 +1688,18 @@ impl Build {
16881688
return;
16891689
}
16901690
}
1691-
// workaround for https://github.com/rust-lang/rust/issues/127126
1692-
// retry linking or copying up to 10 times or until success.
1693-
let result: io::Result<()> = retry(10, || {
1694-
if let Ok(()) = fs::hard_link(&src, dst) {
1695-
// Attempt to "easy copy" by creating a hard link
1696-
// (symlinks don't work on windows), but if that fails
1697-
// just fall back to a slow `copy` operation.
1698-
Ok(())
1699-
} else {
1700-
fs::copy(&src, dst)?;
1701-
t!(fs::set_permissions(dst, metadata.permissions()));
1702-
let atime = FileTime::from_last_access_time(&metadata);
1703-
let mtime = FileTime::from_last_modification_time(&metadata);
1704-
t!(filetime::set_file_times(dst, atime, mtime));
1705-
Ok(())
1691+
if let Ok(()) = fs::hard_link(&src, dst) {
1692+
// Attempt to "easy copy" by creating a hard link
1693+
// (symlinks don't work on windows), but if that fails
1694+
// just fall back to a slow `copy` operation.
1695+
} else {
1696+
if let Err(e) = fs::copy(&src, dst) {
1697+
panic!("failed to copy `{}` to `{}`: {}", src.display(), dst.display(), e)
17061698
}
1707-
});
1708-
if let Err(e) = result {
1709-
panic!("failed to copy `{}` to `{}`: {}", src.display(), dst.display(), e)
1699+
t!(fs::set_permissions(dst, metadata.permissions()));
1700+
let atime = FileTime::from_last_access_time(&metadata);
1701+
let mtime = FileTime::from_last_modification_time(&metadata);
1702+
t!(filetime::set_file_times(dst, atime, mtime));
17101703
}
17111704
}
17121705

0 commit comments

Comments
 (0)