Fix fs-lock impl

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>
This commit is contained in:
Jiahao XU 2025-02-22 23:08:20 +11:00 committed by GitHub
parent 3e5f41e27e
commit ce65159cc7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -20,11 +20,10 @@ pub struct FileLock(
impl FileLock { impl FileLock {
fn new(file: File) -> Self { fn new(file: File) -> Self {
Self( #[cfg(not(feature = "tracing"))]
file, Self(file)
#[cfg(feature = "tracing")] #[cfg(feature = "tracing")]
None, Self(file, None)
)
} }
/// Take an exclusive lock on a [`File`]. /// Take an exclusive lock on a [`File`].
@ -33,7 +32,7 @@ impl FileLock {
pub fn new_exclusive(file: File) -> io::Result<Self> { pub fn new_exclusive(file: File) -> io::Result<Self> {
FileExt::lock_exclusive(&file)?; FileExt::lock_exclusive(&file)?;
Ok(Self:new(file)) Ok(Self::new(file))
} }
/// Try to take an exclusive lock on a [`File`]. /// Try to take an exclusive lock on a [`File`].