Skip to content

Commit 0557335

Browse files
committed
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.
2 parents 776ba5f + 60aa78e commit 0557335

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/cargo/util/flock.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ use fs2::{lock_contended_error, FileExt};
77
#[allow(unused_imports)]
88
use libc;
99
use termcolor::Color::Cyan;
10+
#[cfg(windows)]
11+
use winapi::shared::winerror::ERROR_INVALID_FUNCTION;
1012

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

316+
#[cfg(windows)]
317+
Err(ref e) if e.raw_os_error() == Some(ERROR_INVALID_FUNCTION as i32) => return Ok(()),
318+
314319
Err(e) => {
315320
if e.raw_os_error() != lock_contended_error().raw_os_error() {
316321
let e = failure::Error::from(e);

0 commit comments

Comments
 (0)