fix: resolve compilation errors in API routes and diff pipe setup
Co-authored-by: aider (openai/andrew/openrouter/qwen/qwen3-coder) <aider@aider.chat>
This commit is contained in:
@@ -75,15 +75,25 @@ 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> {
|
fn setup_diff_pipes() -> Result<((libc::c_int, libc::c_int), (libc::c_int, libc::c_int)), anyhow::Error> {
|
||||||
use nix::unistd::pipe2;
|
use nix::unistd::pipe;
|
||||||
use nix::fcntl::OFlag;
|
use nix::fcntl::{fcntl, FcntlArg, FdFlag};
|
||||||
use nix::Error as NixError;
|
use nix::Error as NixError;
|
||||||
|
|
||||||
// Create pipes for diff's input with CLOEXEC flag
|
// Create pipes for diff's input
|
||||||
let (fd_a_read, fd_a_write) =
|
let (fd_a_read, fd_a_write) =
|
||||||
pipe2(OFlag::O_CLOEXEC).map_err(|e: NixError| anyhow::anyhow!("Failed to create pipe A: {}", e))?;
|
pipe().map_err(|e: NixError| anyhow::anyhow!("Failed to create pipe A: {}", e))?;
|
||||||
let (fd_b_read, fd_b_write) =
|
let (fd_b_read, fd_b_write) =
|
||||||
pipe2(OFlag::O_CLOEXEC).map_err(|e: NixError| anyhow::anyhow!("Failed to create pipe B: {}", e))?;
|
pipe().map_err(|e: NixError| anyhow::anyhow!("Failed to create pipe B: {}", e))?;
|
||||||
|
|
||||||
|
// Set FD_CLOEXEC on all file descriptors
|
||||||
|
fcntl(fd_a_read, FcntlArg::F_SETFD(FdFlag::FD_CLOEXEC))
|
||||||
|
.map_err(|e| anyhow::anyhow!("Failed to set FD_CLOEXEC on fd_a_read: {}", e))?;
|
||||||
|
fcntl(fd_a_write, FcntlArg::F_SETFD(FdFlag::FD_CLOEXEC))
|
||||||
|
.map_err(|e| anyhow::anyhow!("Failed to set FD_CLOEXEC on fd_a_write: {}", e))?;
|
||||||
|
fcntl(fd_b_read, FcntlArg::F_SETFD(FdFlag::FD_CLOEXEC))
|
||||||
|
.map_err(|e| anyhow::anyhow!("Failed to set FD_CLOEXEC on fd_b_read: {}", e))?;
|
||||||
|
fcntl(fd_b_write, FcntlArg::F_SETFD(FdFlag::FD_CLOEXEC))
|
||||||
|
.map_err(|e| anyhow::anyhow!("Failed to set FD_CLOEXEC on fd_b_write: {}", e))?;
|
||||||
|
|
||||||
Ok(((fd_a_read.into(), fd_a_write.into()), (fd_b_read.into(), fd_b_write.into())))
|
Ok(((fd_a_read.into(), fd_a_write.into()), (fd_b_read.into(), fd_b_write.into())))
|
||||||
}
|
}
|
||||||
@@ -95,23 +105,6 @@ fn setup_fd_guards(fd_a_read: libc::c_int, fd_b_read: libc::c_int) -> (FdGuard,
|
|||||||
(fd_a_read_guard, fd_b_read_guard)
|
(fd_a_read_guard, fd_b_read_guard)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_fd_cloexec(fd_a_write: libc::c_int, fd_b_write: libc::c_int) -> Result<(), anyhow::Error> {
|
|
||||||
use nix::fcntl::{fcntl, FcntlArg, FdFlag};
|
|
||||||
|
|
||||||
// Set FD_CLOEXEC on write ends
|
|
||||||
fcntl(
|
|
||||||
fd_a_write,
|
|
||||||
FcntlArg::F_SETFD(FdFlag::FD_CLOEXEC),
|
|
||||||
)
|
|
||||||
.map_err(|e| anyhow::anyhow!("Failed to set FD_CLOEXEC on fd_a_write: {}", e))?;
|
|
||||||
fcntl(
|
|
||||||
fd_b_write,
|
|
||||||
FcntlArg::F_SETFD(FdFlag::FD_CLOEXEC),
|
|
||||||
)
|
|
||||||
.map_err(|e| anyhow::anyhow!("Failed to set FD_CLOEXEC on fd_b_write: {}", e))?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn spawn_diff_process(
|
fn spawn_diff_process(
|
||||||
item_a_id: i64,
|
item_a_id: i64,
|
||||||
|
|||||||
@@ -16,11 +16,11 @@ use utoipa_swagger_ui::SwaggerUi;
|
|||||||
status::handle_status,
|
status::handle_status,
|
||||||
item::handle_list_items,
|
item::handle_list_items,
|
||||||
item::handle_post_item,
|
item::handle_post_item,
|
||||||
item::handle_delete_item,
|
|
||||||
item::handle_get_item_latest,
|
item::handle_get_item_latest,
|
||||||
item::handle_get_item_latest_meta,
|
item::handle_get_item_latest_meta,
|
||||||
item::handle_get_item_latest_content,
|
item::handle_get_item_latest_content,
|
||||||
item::handle_get_item,
|
item::handle_get_item,
|
||||||
|
item::handle_delete_item,
|
||||||
item::handle_get_item_meta,
|
item::handle_get_item_meta,
|
||||||
item::handle_get_item_content,
|
item::handle_get_item_content,
|
||||||
),
|
),
|
||||||
@@ -47,9 +47,9 @@ pub fn add_routes(router: Router<AppState>) -> Router<AppState> {
|
|||||||
.route("/api/item/latest", get(item::handle_get_item_latest))
|
.route("/api/item/latest", get(item::handle_get_item_latest))
|
||||||
.route("/api/item/latest/meta", get(item::handle_get_item_latest_meta))
|
.route("/api/item/latest/meta", get(item::handle_get_item_latest_meta))
|
||||||
.route("/api/item/latest/content", get(item::handle_get_item_latest_content))
|
.route("/api/item/latest/content", get(item::handle_get_item_latest_content))
|
||||||
.route("/api/item/:id", get(item::handle_get_item).delete(item::handle_delete_item))
|
.route("/api/item/:item_id", get(item::handle_get_item).delete(item::handle_delete_item))
|
||||||
.route("/api/item/:id/meta", get(item::handle_get_item_meta))
|
.route("/api/item/:item_id/meta", get(item::handle_get_item_meta))
|
||||||
.route("/api/item/:id/content", get(item::handle_get_item_content))
|
.route("/api/item/:item_id/content", get(item::handle_get_item_content))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_docs_routes(router: Router<AppState>) -> Router<AppState> {
|
pub fn add_docs_routes(router: Router<AppState>) -> Router<AppState> {
|
||||||
|
|||||||
Reference in New Issue
Block a user