mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-18 01:44:04 +00:00
Try renaming the file if removing fails
This commit is contained in:
parent
716752ebe6
commit
3d6cc60535
@ -26,6 +26,7 @@ use std::path::{Path, PathBuf};
|
||||
use std::process::{Command, Stdio};
|
||||
use std::str;
|
||||
use std::sync::OnceLock;
|
||||
use std::time::SystemTime;
|
||||
|
||||
use build_helper::ci::{gha, CiEnv};
|
||||
use build_helper::exit;
|
||||
@ -1676,7 +1677,14 @@ impl Build {
|
||||
if src == dst {
|
||||
return;
|
||||
}
|
||||
let _ = fs::remove_file(dst);
|
||||
if let Err(e) = fs::remove_file(dst) {
|
||||
if e.kind() != io::ErrorKind::NotFound {
|
||||
// workaround for https://github.com/rust-lang/rust/issues/127126
|
||||
// if removing the file fails, attempt to rename it instead.
|
||||
let now = t!(SystemTime::now().duration_since(SystemTime::UNIX_EPOCH));
|
||||
let _ = fs::rename(dst, format!("{}-{}", dst.display(), now.as_nanos()));
|
||||
}
|
||||
}
|
||||
let metadata = t!(src.symlink_metadata(), format!("src = {}", src.display()));
|
||||
let mut src = src.to_path_buf();
|
||||
if metadata.file_type().is_symlink() {
|
||||
|
Loading…
Reference in New Issue
Block a user