feat: update dependencies and remove binary and command meta plugins

This commit is contained in:
Andrew Phillips
2025-08-28 13:11:19 -03:00
committed by Andrew Phillips (aider)
parent 40e4fcc74a
commit 52dc8cea32
5 changed files with 78 additions and 399 deletions

View File

@@ -4,6 +4,7 @@ use std::io::Read;
use std::os::fd::FromRawFd;
use crate::config;
use crate::services::item_service::ItemService;
use log::debug;
fn validate_diff_args(cmd: &mut Command, ids: &Vec<i64>, tags: &Vec<String>) {
if !tags.is_empty() {
@@ -35,8 +36,8 @@ fn fetch_and_validate_items(
.get_item(conn, ids[1])
.with_context(|| format!("Unable to find second item (ID: {}) in database", ids[1]))?;
log::debug!("MAIN: Found item A {:?}", item_a.item);
log::debug!("MAIN: Found item B {:?}", item_b.item);
debug!("MAIN: Found item A {:?}", item_a.item);
debug!("MAIN: Found item B {:?}", item_b.item);
Ok((item_a, item_b))
}
@@ -94,7 +95,7 @@ fn spawn_diff_process(
fd_a_read: libc::c_int,
fd_b_read: libc::c_int,
) -> Result<std::process::Child, anyhow::Error> {
log::debug!("MAIN: Creating child process for diff");
debug!("MAIN: Creating child process for diff");
let mut diff_command = std::process::Command::new("diff");
diff_command
.arg("-u")
@@ -157,10 +158,10 @@ fn write_item_to_pipe(
let mut reader = engine.open(item_path)
.map_err(|e| anyhow::anyhow!("Failed to open item: {}", e))?;
log::debug!("THREAD: Sending item to diff");
debug!("THREAD: Sending item to diff");
std::io::copy(&mut reader, &mut buffered_pipe_writer)
.map_err(|e| anyhow::anyhow!("Failed to copy item to pipe: {}", e))?;
log::debug!("THREAD: Done sending item to diff");
debug!("THREAD: Done sending item to diff");
Ok(())
}
@@ -188,12 +189,12 @@ fn execute_diff_command(
.take()
.expect("BUG: Failed to capture diff stderr pipe");
log::debug!("MAIN: Creating threads for diff I/O");
debug!("MAIN: Creating threads for diff I/O");
// Thread to read diff's standard output
let stdout_reader_thread = std::thread::spawn(move || {
let mut output_buffer = Vec::new();
log::debug!("STDOUT_READER: Reading diff stdout");
debug!("STDOUT_READER: Reading diff stdout");
// child_stdout_pipe is a ChildStdout, which implements std::io::Read
child_stdout_pipe
.read_to_end(&mut output_buffer)
@@ -204,7 +205,7 @@ fn execute_diff_command(
// Thread to read diff's standard error
let stderr_reader_thread = std::thread::spawn(move || {
let mut error_buffer = Vec::new();
log::debug!("STDERR_READER: Reading diff stderr");
debug!("STDERR_READER: Reading diff stderr");
child_stderr_pipe
.read_to_end(&mut error_buffer)
.map_err(|e| anyhow::anyhow!("Failed to read diff stderr: {}", e))
@@ -238,7 +239,7 @@ fn handle_diff_output(
match diff_status.code() {
Some(0) => {
// Exit code 0: No differences
log::debug!("MAIN: Diff successful, no differences found.");
debug!("MAIN: Diff successful, no differences found.");
// Typically, diff -u doesn't print to stdout if no differences.
// But if it did, it would be shown here.
if !stdout_capture_result.is_empty() {
@@ -247,7 +248,7 @@ fn handle_diff_output(
}
Some(1) => {
// Exit code 1: Differences found
log::debug!("MAIN: Diff successful, differences found.");
debug!("MAIN: Diff successful, differences found.");
println!("{}", String::from_utf8_lossy(&stdout_capture_result));
}
Some(error_code) => {
@@ -335,10 +336,10 @@ pub fn mode_diff(
spawn_writer_thread(item_path_b.clone(), compression_type_b.clone(), fd_b_write);
// Wait for writer threads to complete (meaning all input has been sent to diff)
log::debug!("MAIN: Waiting on writer thread for item A");
debug!("MAIN: Waiting on writer thread for item A");
match writer_thread_a.join() {
Ok(Ok(())) => {
log::debug!("MAIN: Writer thread for item A completed successfully.");
debug!("MAIN: Writer thread for item A completed successfully.");
}
Ok(Err(e)) => {
return Err(anyhow::anyhow!("Writer thread for item A failed: {}", e));
@@ -352,10 +353,10 @@ pub fn mode_diff(
}
}
log::debug!("MAIN: Waiting on writer thread for item B");
debug!("MAIN: Waiting on writer thread for item B");
match writer_thread_b.join() {
Ok(Ok(())) => {
log::debug!("MAIN: Writer thread for item B completed successfully.");
debug!("MAIN: Writer thread for item B completed successfully.");
}
Ok(Err(e)) => {
return Err(anyhow::anyhow!("Writer thread for item B failed: {}", e));
@@ -369,18 +370,18 @@ pub fn mode_diff(
}
}
log::debug!("MAIN: Done waiting on input-writer threads.");
debug!("MAIN: Done waiting on input-writer threads.");
// Now that all input has been sent, the diff process will run to completion.
// We can read its output. This will block until the process is finished.
let (stdout_capture_result, stderr_capture_result) = execute_diff_command(&mut child_process)?;
// wait for the diff child process to terminate.
log::debug!("MAIN: Waiting for diff child process to finish...");
debug!("MAIN: Waiting for diff child process to finish...");
let diff_status = child_process
.wait()
.map_err(|e| anyhow::anyhow!("Failed to wait on diff command: {}", e))?;
log::debug!(
debug!(
"MAIN: Diff child process finished with status: {}",
diff_status
);