From d6f216facdaebe5de7121aa6962569b883d719a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Mon, 20 Jul 2026 21:20:43 -0400 Subject: [PATCH] Fix Windows build: portable lock-contention check in graph_project MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../codegen/kigi-shell/src/session/graph_project.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/codegen/kigi-shell/src/session/graph_project.rs b/crates/codegen/kigi-shell/src/session/graph_project.rs index 9549a42..991e8d5 100644 --- a/crates/codegen/kigi-shell/src/session/graph_project.rs +++ b/crates/codegen/kigi-shell/src/session/graph_project.rs @@ -78,10 +78,15 @@ pub fn try_acquire_writer(dir: &Path) -> std::io::Result { .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), } }