Fix use of fs4::fs_std::FileExt::try_lock*

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>
This commit is contained in:
Jiahao XU 2025-03-01 17:48:32 +11:00 committed by GitHub
parent 0f32274a6c
commit c836f0026a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -44,7 +44,7 @@ impl FileLock {
/// Note that this operation is blocking, and should not be called in async contexts. /// Note that this operation is blocking, and should not be called in async contexts.
pub fn new_try_exclusive(file: File) -> Result<Self, (File, Option<io::Error>)> { pub fn new_try_exclusive(file: File) -> Result<Self, (File, Option<io::Error>)> {
match FileExt::try_lock_exclusive(&file) { match FileExt::try_lock_exclusive(&file) {
Ok(()) => Ok(Self::new(file)), Ok(_) => Ok(Self::new(file)),
Err(e) if e.raw_os_error() == fs4::lock_contended_error().raw_os_error() => { Err(e) if e.raw_os_error() == fs4::lock_contended_error().raw_os_error() => {
Err((file, None)) Err((file, None))
} }
@ -70,7 +70,7 @@ impl FileLock {
/// Note that this operation is blocking, and should not be called in async contexts. /// Note that this operation is blocking, and should not be called in async contexts.
pub fn new_try_shared(file: File) -> Result<Self, (File, Option<io::Error>)> { pub fn new_try_shared(file: File) -> Result<Self, (File, Option<io::Error>)> {
match FileExt::try_lock_shared(&file) { match FileExt::try_lock_shared(&file) {
Ok(()) => Ok(Self::new(file)), Ok(_) => Ok(Self::new(file)),
Err(e) if e.raw_os_error() == fs4::lock_contended_error().raw_os_error() => { Err(e) if e.raw_os_error() == fs4::lock_contended_error().raw_os_error() => {
Err((file, None)) Err((file, None))
} }