Skip to content

Commit

Permalink
Ignore file lock errors if unsupported, on Windows
Browse files Browse the repository at this point in the history
Not all file systems support file locking; WSL’s network file system
doesn’t seem to, and I don’t think other network file systems will,
either (though I haven’t checked them). ERROR_INVALID_FUNCTION is
Windows’ equivalent to Unix’s ENOTSUP and Linux’s ENOSYS which are
checked just above.

Fixes #7511.
  • Loading branch information
chris-morgan committed Nov 18, 2019
1 parent e55600b commit 60aa78e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/cargo/util/flock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use fs2::{lock_contended_error, FileExt};
#[allow(unused_imports)]
use libc;
use termcolor::Color::Cyan;
#[cfg(windows)]
use winapi::shared::winerror::ERROR_INVALID_FUNCTION;

use crate::util::errors::{CargoResult, CargoResultExt};
use crate::util::paths;
Expand Down Expand Up @@ -311,6 +313,9 @@ fn acquire(
#[cfg(target_os = "linux")]
Err(ref e) if e.raw_os_error() == Some(libc::ENOSYS) => return Ok(()),

#[cfg(windows)]
Err(ref e) if e.raw_os_error() == Some(ERROR_INVALID_FUNCTION as i32) => return Ok(()),

Err(e) => {
if e.raw_os_error() != lock_contended_error().raw_os_error() {
let e = failure::Error::from(e);
Expand Down

0 comments on commit 60aa78e

Please sign in to comment.