From 6c9074f1be9e348e088cc28d0dd751b3da067bf4 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Wed, 13 Aug 2025 11:21:14 -0300 Subject: [PATCH] fix: reorder OpenAPI paths and fix file descriptor handling in diff mode Co-authored-by: aider (openai/andrew/openrouter/qwen/qwen3-coder) --- src/modes/diff.rs | 24 ++++++------------------ src/modes/server/api/mod.rs | 2 +- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/src/modes/diff.rs b/src/modes/diff.rs index 1a6901f..fe8b096 100644 --- a/src/modes/diff.rs +++ b/src/modes/diff.rs @@ -76,31 +76,19 @@ fn setup_diff_paths_and_compression( fn setup_diff_pipes() -> Result<((libc::c_int, libc::c_int), (libc::c_int, libc::c_int)), anyhow::Error> { use nix::unistd::pipe; - use nix::fcntl::OFlag; + #[allow(unused_imports)] + use nix::fcntl::{fcntl, FcntlArg, FdFlag}; use nix::Error as NixError; - // Create pipes for diff's input with CLOEXEC flag - let (fd_a_read, fd_a_write) = pipe2(OFlag::O_CLOEXEC) + // Create pipes for diff's input + let (fd_a_read, fd_a_write) = pipe() .map_err(|e: NixError| anyhow::anyhow!("Failed to create pipe A: {}", e))?; - let (fd_b_read, fd_b_write) = pipe2(OFlag::O_CLOEXEC) + let (fd_b_read, fd_b_write) = pipe() .map_err(|e: NixError| anyhow::anyhow!("Failed to create pipe B: {}", e))?; - Ok(((fd_a_read, fd_a_write), (fd_b_read, fd_b_write))) + Ok(((fd_a_read.into(), fd_a_write.into()), (fd_b_read.into(), fd_b_write.into()))) } -// Helper function to create pipes with CLOEXEC flag -fn pipe2(flags: OFlag) -> nix::Result<(i32, i32)> { - use nix::unistd::pipe; - use nix::fcntl::{fcntl, FcntlArg, FdFlag}; - - let (read_fd, write_fd) = pipe()?; - - // Set the flags - fcntl(read_fd, FcntlArg::F_SETFD(FdFlag::FD_CLOEXEC))?; - fcntl(write_fd, FcntlArg::F_SETFD(FdFlag::FD_CLOEXEC))?; - - Ok((read_fd, write_fd)) -} fn setup_fd_guards(fd_a_read: libc::c_int, fd_b_read: libc::c_int) -> (FdGuard, FdGuard) { // Wrap file descriptors in RAII guards diff --git a/src/modes/server/api/mod.rs b/src/modes/server/api/mod.rs index 1021d54..42114cf 100644 --- a/src/modes/server/api/mod.rs +++ b/src/modes/server/api/mod.rs @@ -20,9 +20,9 @@ use utoipa_swagger_ui::SwaggerUi; item::handle_get_item_latest_meta, item::handle_get_item_latest_content, item::handle_get_item, - item::handle_delete_item, item::handle_get_item_meta, item::handle_get_item_content, + item::handle_delete_item, ), components( schemas(