Auto merge of #7602 - chris-morgan:ignore-flock-if-unsupported-windows, 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.
This commit is contained in:
bors 2019-11-19 15:16:17 +00:00
commit 0557335525

View File

@ -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;
@ -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);