Skip to content

Commit

Permalink
Auto merge of #7602 - chris-morgan:ignore-flock-if-unsupported-window…
Browse files Browse the repository at this point in the history
…s, r=alexcrichton

Ignore file lock errors if unsupported, on Windows

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
bors committed Nov 19, 2019
2 parents 776ba5f + 60aa78e commit 0557335
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 0557335

Please sign in to comment.