Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions crates/uv/src/commands/cache_clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,19 @@ pub(crate) fn cache_clean(
return Ok(ExitStatus::Success);
}

let cache = if force {
// If `--force` is used, attempt to acquire the exclusive lock but do not block.
match cache.with_exclusive_lock_no_wait() {
Ok(cache) => cache,
Err(cache) => {
debug!("Cache is currently in use, proceeding due to `--force`");
cache
}
let cache = match cache.with_exclusive_lock_no_wait() {
Ok(cache) => cache,
Err(cache) if force => {
debug!("Cache is currently in use, proceeding due to `--force`");
cache
}
Err(cache) => {
writeln!(
printer.stderr(),
"Cache is currently in-use, waiting for other uv processes to finish (use `--force` to override)"
)?;
cache.with_exclusive_lock()?
}
} else {
cache.with_exclusive_lock()?
};

let summary = if packages.is_empty() {
Expand Down
22 changes: 12 additions & 10 deletions crates/uv/src/commands/cache_prune.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,19 @@ pub(crate) fn cache_prune(
return Ok(ExitStatus::Success);
}

let cache = if force {
// If `--force` is used, attempt to acquire the exclusive lock but do not block.
match cache.with_exclusive_lock_no_wait() {
Ok(cache) => cache,
Err(cache) => {
debug!("Cache is currently in use, proceeding due to `--force`");
cache
}
let cache = match cache.with_exclusive_lock_no_wait() {
Ok(cache) => cache,
Err(cache) if force => {
debug!("Cache is currently in use, proceeding due to `--force`");
cache
}
Err(cache) => {
writeln!(
printer.stderr(),
"Cache is currently in-use, waiting for other uv processes to finish (use `--force` to override)"
)?;
cache.with_exclusive_lock()?
}
} else {
cache.with_exclusive_lock()?
};

writeln!(
Expand Down
Loading