mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-24 22:30:03 +00:00
Fix fs-lock error on nightly (#2059)
* Fix fs-lock error on nightly Since File::*lock* API is stablised on 1.87, it overrides fs4::fs_std::FileExt Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * Fix other fs-lock method Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * Fix unit-tests when no test is run Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> --------- Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>
This commit is contained in:
parent
ac0e34cc77
commit
395a586265
2 changed files with 6 additions and 6 deletions
|
@ -19,7 +19,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_exclusive(file: File) -> io::Result<Self> {
|
pub fn new_exclusive(file: File) -> io::Result<Self> {
|
||||||
file.lock_exclusive()?;
|
FileExt::lock_exclusive(&file)?;
|
||||||
|
|
||||||
Ok(Self(file))
|
Ok(Self(file))
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,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 file.try_lock_exclusive() {
|
match FileExt::try_lock_exclusive(&file) {
|
||||||
Ok(()) => Ok(Self(file)),
|
Ok(()) => Ok(Self(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))
|
||||||
|
@ -45,7 +45,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_shared(file: File) -> io::Result<Self> {
|
pub fn new_shared(file: File) -> io::Result<Self> {
|
||||||
file.lock_shared()?;
|
FileExt::lock_shared(&file)?;
|
||||||
|
|
||||||
Ok(Self(file))
|
Ok(Self(file))
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,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 file.try_lock_shared() {
|
match FileExt::try_lock_shared(&file) {
|
||||||
Ok(()) => Ok(Self(file)),
|
Ok(()) => Ok(Self(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 {
|
||||||
|
|
||||||
impl Drop for FileLock {
|
impl Drop for FileLock {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
let _ = self.unlock();
|
let _ = FileExt::unlock(&self.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
justfile
2
justfile
|
@ -257,7 +257,7 @@ e2e-tests: e2e-test-live e2e-test-manifest-path e2e-test-git e2e-test-other-repo
|
||||||
|
|
||||||
unit-tests: print-env
|
unit-tests: print-env
|
||||||
cargo test --no-run --target {{target}}
|
cargo test --no-run --target {{target}}
|
||||||
cargo nextest run --target {{target}} {{cargo-nextest-additional-args}}
|
cargo nextest run --target {{target}} --no-tests=pass {{cargo-nextest-additional-args}}
|
||||||
cargo test --doc --target {{target}}
|
cargo test --doc --target {{target}}
|
||||||
|
|
||||||
test: unit-tests build e2e-tests
|
test: unit-tests build e2e-tests
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue