diff --git a/codex-rs/Cargo.lock b/codex-rs/Cargo.lock index 80809434..dc9385d9 100644 --- a/codex-rs/Cargo.lock +++ b/codex-rs/Cargo.lock @@ -703,7 +703,6 @@ dependencies = [ "dirs", "env-flags", "eventsource-stream", - "fs2", "futures", "landlock", "libc", @@ -1745,16 +1744,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "fs2" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "futures" version = "0.3.31" diff --git a/codex-rs/core/Cargo.toml b/codex-rs/core/Cargo.toml index 78942ff6..52c731ae 100644 --- a/codex-rs/core/Cargo.toml +++ b/codex-rs/core/Cargo.toml @@ -23,7 +23,6 @@ codex-protocol = { path = "../protocol" } dirs = "6" env-flags = "0.1.1" eventsource-stream = "0.2.3" -fs2 = "0.4.3" futures = "0.3" libc = "0.2.175" mcp-types = { path = "../mcp-types" } diff --git a/codex-rs/core/src/message_history.rs b/codex-rs/core/src/message_history.rs index 29970c2a..9f13abab 100644 --- a/codex-rs/core/src/message_history.rs +++ b/codex-rs/core/src/message_history.rs @@ -125,16 +125,18 @@ pub(crate) async fn append_entry(text: &str, session_id: &Uuid, config: &Config) /// times if the lock is currently held by another process. This prevents a /// potential indefinite wait while still giving other writers some time to /// finish their operation. -async fn acquire_exclusive_lock_with_retry(file: &std::fs::File) -> Result<()> { +async fn acquire_exclusive_lock_with_retry(file: &File) -> Result<()> { use tokio::time::sleep; for _ in 0..MAX_RETRIES { - match fs2::FileExt::try_lock_exclusive(file) { + match file.try_lock() { Ok(()) => return Ok(()), - Err(e) if e.kind() == std::io::ErrorKind::WouldBlock => { - sleep(RETRY_SLEEP).await; - } - Err(e) => return Err(e), + Err(e) => match e { + std::fs::TryLockError::WouldBlock => { + sleep(RETRY_SLEEP).await; + } + other => return Err(other.into()), + }, } } @@ -259,12 +261,14 @@ pub(crate) fn lookup(log_id: u64, offset: usize, config: &Config) -> Option Result<()> { for _ in 0..MAX_RETRIES { - match fs2::FileExt::try_lock_shared(file) { + match file.try_lock_shared() { Ok(()) => return Ok(()), - Err(e) if e.kind() == std::io::ErrorKind::WouldBlock => { - std::thread::sleep(RETRY_SLEEP); - } - Err(e) => return Err(e), + Err(e) => match e { + std::fs::TryLockError::WouldBlock => { + std::thread::sleep(RETRY_SLEEP); + } + other => return Err(other.into()), + }, } }