mirror of https://github.com/astral-sh/uv
Lock during installs in `uv format` to prevent races (#15551)
Closes https://github.com/astral-sh/uv/issues/15513
This commit is contained in:
parent
0bde9e4b8f
commit
9b1328af3d
|
|
@ -165,8 +165,6 @@ pub async fn bin_install(
|
||||||
) -> Result<PathBuf, Error> {
|
) -> Result<PathBuf, Error> {
|
||||||
let platform = Platform::from_env()?;
|
let platform = Platform::from_env()?;
|
||||||
let platform_name = platform.as_cargo_dist_triple();
|
let platform_name = platform.as_cargo_dist_triple();
|
||||||
|
|
||||||
// Check the cache first
|
|
||||||
let cache_entry = CacheEntry::new(
|
let cache_entry = CacheEntry::new(
|
||||||
cache
|
cache
|
||||||
.bucket(CacheBucket::Binaries)
|
.bucket(CacheBucket::Binaries)
|
||||||
|
|
@ -176,6 +174,8 @@ pub async fn bin_install(
|
||||||
binary.executable(),
|
binary.executable(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Lock the directory to prevent racing installs
|
||||||
|
let _lock = cache_entry.with_file(".lock").lock().await?;
|
||||||
if cache_entry.path().exists() {
|
if cache_entry.path().exists() {
|
||||||
return Ok(cache_entry.into_path_buf());
|
return Ok(cache_entry.into_path_buf());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue