Skip to content
Open
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
27 changes: 20 additions & 7 deletions crates/uv-fs/src/locked_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use thiserror::Error;
use tracing::{debug, error, info, trace, warn};

use uv_static::EnvVars;
#[cfg(windows)]
use windows::Win32::Foundation::ERROR_LOCK_VIOLATION;

use crate::{Simplified, is_known_already_locked_error};

Expand Down Expand Up @@ -422,13 +424,24 @@ impl LockedFile {
#[cfg(feature = "tokio")]
impl Drop for LockedFile {
fn drop(&mut self) {
if let Err(err) = self.unlock() {
error!(
"Failed to unlock resource at `{}`; program may be stuck: {err}",
self.0.path().display()
);
} else {
trace!("Released lock at `{}`", self.0.path().display());
match self.unlock() {
Ok(()) => {
trace!("Released lock at `{}`", self.0.path().display());
}
// See <https://bugs.winehq.org/show_bug.cgi?id=59711>
#[cfg(windows)]
Err(err)
if uv_windows::is_wine()
&& err.raw_os_error() == Some(ERROR_LOCK_VIOLATION.0 as i32) =>
{
trace!("Released lock at `{}`", self.0.path().display());
}
Err(err) => {
error!(
"Failed to unlock resource at `{}`; program may be stuck: {err}",
self.0.path().display()
);
}
}
}
}
Loading