Fix Windows build: portable lock-contention check in graph_project
Release / build (aarch64-apple-darwin) (push) Waiting to run
Release / build (x86_64-apple-darwin) (push) Waiting to run
Release / build (aarch64-unknown-linux-gnu) (push) Waiting to run
Release / build (x86_64-pc-windows-msvc) (push) Waiting to run
Release / publish GitHub Release (push) Blocked by required conditions
Release / build (x86_64-unknown-linux-gnu) (push) Failing after 7s

libc::EWOULDBLOCK is unix-only (kigi-shell links libc behind cfg(unix));
the v0.1.3 windows-msvc release build failed on it. fs2 exposes
lock_contended_error() precisely as the cross-platform classifier
(EWOULDBLOCK on unix, ERROR_LOCK_VIOLATION on Windows) — use it instead
of the raw errno. No behavior change on unix; graph_project lock tests
green.
This commit is contained in:
2026-07-20 21:20:43 -04:00
parent 4d2cf7ffd4
commit d6f216facd
@@ -78,10 +78,15 @@ pub fn try_acquire_writer(dir: &Path) -> std::io::Result<LockOutcome> {
.open(lock_file_path(dir))?;
match file.try_lock_exclusive() {
Ok(()) => Ok(LockOutcome::Acquired(ProjectGraphLock { _file: file })),
Err(err) if err.kind() == std::io::ErrorKind::WouldBlock => Ok(LockOutcome::Busy),
// fs2 maps "already locked" differently per platform; treat the
// documented contention errno as Busy too.
Err(err) if err.raw_os_error() == Some(libc::EWOULDBLOCK) => Ok(LockOutcome::Busy),
// fs2 maps contention differently per platform (EWOULDBLOCK on
// unix, ERROR_LOCK_VIOLATION on Windows); its
// `lock_contended_error()` is the portable classifier.
Err(err)
if err.kind() == std::io::ErrorKind::WouldBlock
|| err.raw_os_error() == fs2::lock_contended_error().raw_os_error() =>
{
Ok(LockOutcome::Busy)
}
Err(err) => Err(err),
}
}