fix: implement debug for meta plugin program and remove unused imports

Co-authored-by: aider (openai/andrew/openrouter/qwen/qwen3-coder) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-18 08:03:55 -03:00
parent 3dac2d3073
commit 2424c543d6
5 changed files with 16 additions and 6 deletions

View File

@@ -1,6 +1,5 @@
use anyhow::Result; use anyhow::Result;
use std::io; use std::io;
use std::io::Write;
use rusqlite::Connection; use rusqlite::Connection;
use log::debug; use log::debug;

View File

@@ -1,7 +1,6 @@
use anyhow::Result; use anyhow::Result;
use sha2::{Digest, Sha256}; use sha2::{Digest, Sha256};
use std::io; use std::io;
use std::io::Write;
use std::time::Instant; use std::time::Instant;
use crate::meta_plugin::MetaPlugin; use crate::meta_plugin::MetaPlugin;

View File

@@ -132,7 +132,7 @@ impl MetaPlugin for MagicFileMetaPlugin {
// Check if we've reached our buffer limit and save if so // Check if we've reached our buffer limit and save if so
if self.buffer.len() >= self.max_buffer_size && !self.is_saved { if self.buffer.len() >= self.max_buffer_size && !self.is_saved {
if let (Some(conn), Some(item_id)) = (self.conn, self.item_id) { if let (Some(_conn), Some(_item_id)) = (self.conn, self.item_id) {
if let Err(e) = self.save_all_magic_metadata() { if let Err(e) = self.save_all_magic_metadata() {
eprintln!("Warning: Failed to save magic metadata early: {}", e); eprintln!("Warning: Failed to save magic metadata early: {}", e);
} }

View File

@@ -7,7 +7,6 @@ use which::which;
use crate::meta_plugin::MetaPlugin; use crate::meta_plugin::MetaPlugin;
#[derive(Debug)]
pub struct MetaPluginProgram { pub struct MetaPluginProgram {
pub program: String, pub program: String,
pub args: Vec<String>, pub args: Vec<String>,
@@ -18,6 +17,20 @@ pub struct MetaPluginProgram {
writer: Option<Box<dyn Write>>, writer: Option<Box<dyn Write>>,
} }
impl std::fmt::Debug for MetaPluginProgram {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("MetaPluginProgram")
.field("program", &self.program)
.field("args", &self.args)
.field("supported", &self.supported)
.field("meta_name", &self.meta_name)
.field("split_whitespace", &self.split_whitespace)
.field("process", &self.process)
.field("writer", &"Box<dyn Write>")
.finish()
}
}
impl MetaPluginProgram { impl MetaPluginProgram {
pub fn new(program: &str, args: Vec<&str>, meta_name: String, split_whitespace: bool) -> MetaPluginProgram { pub fn new(program: &str, args: Vec<&str>, meta_name: String, split_whitespace: bool) -> MetaPluginProgram {
let program_path = which(program); let program_path = which(program);
@@ -77,7 +90,7 @@ impl MetaPlugin for MetaPluginProgram {
// Close stdin to signal EOF to the process // Close stdin to signal EOF to the process
self.writer.take(); self.writer.take();
if let Some(mut process) = self.process.take() { if let Some(process) = self.process.take() {
let output = process.wait_with_output() let output = process.wait_with_output()
.map_err(|e| io::Error::new(io::ErrorKind::Other, format!("Failed to wait for process: {}", e)))?; .map_err(|e| io::Error::new(io::ErrorKind::Other, format!("Failed to wait for process: {}", e)))?;

View File

@@ -3,7 +3,6 @@ use gethostname::gethostname;
use local_ip_address::local_ip; use local_ip_address::local_ip;
use dns_lookup::lookup_addr; use dns_lookup::lookup_addr;
use std::io; use std::io;
use std::io::Write;
use std::env; use std::env;
use std::process; use std::process;
use uzers::{get_current_uid, get_current_gid, get_current_username, get_current_groupname}; use uzers::{get_current_uid, get_current_gid, get_current_username, get_current_groupname};