mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-19 10:00:27 +00:00
Try to fix unique file names on Windows
This commit is contained in:
parent
05b3a4bc93
commit
d236fc6abe
1 changed files with 7 additions and 4 deletions
|
@ -188,7 +188,9 @@ impl Expander {
|
||||||
/// Copy the dylib to temp directory to prevent locking in Windows
|
/// Copy the dylib to temp directory to prevent locking in Windows
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
fn ensure_file_with_lock_free_access(path: &Path) -> io::Result<PathBuf> {
|
fn ensure_file_with_lock_free_access(path: &Path) -> io::Result<PathBuf> {
|
||||||
use std::{ffi::OsString, time::SystemTime};
|
use std::collections::hash_map::RandomState;
|
||||||
|
use std::ffi::OsString;
|
||||||
|
use std::hash::{BuildHasher, Hasher};
|
||||||
|
|
||||||
let mut to = std::env::temp_dir();
|
let mut to = std::env::temp_dir();
|
||||||
|
|
||||||
|
@ -199,10 +201,11 @@ fn ensure_file_with_lock_free_access(path: &Path) -> io::Result<PathBuf> {
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
// generate a time deps unique number
|
// Generate a unique number by abusing `HashMap`'s hasher.
|
||||||
let t = SystemTime::now().duration_since(std::time::UNIX_EPOCH).expect("Time went backwards");
|
// Maybe this will also "inspire" a libs team member to finally put `rand` in libstd.
|
||||||
|
let t = RandomState::new().build_hasher().finish();
|
||||||
|
|
||||||
let mut unique_name = OsString::from(t.as_millis().to_string());
|
let mut unique_name = OsString::from(t.to_string());
|
||||||
unique_name.push(file_name);
|
unique_name.push(file_name);
|
||||||
|
|
||||||
to.push(unique_name);
|
to.push(unique_name);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue