fix: remove unused imports and update method signatures
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
use anyhow::Result;
|
||||
use rusqlite::Connection;
|
||||
|
||||
use crate::common::is_binary::is_binary;
|
||||
use crate::common::PIPESIZE;
|
||||
use crate::meta_plugin::MetaPlugin;
|
||||
use crate::meta_plugin::{MetaPlugin, MetaPluginResponse, MetaData};
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct BinaryMetaPlugin {
|
||||
@@ -61,20 +61,6 @@ impl BinaryMetaPlugin {
|
||||
Self::new(None, None)
|
||||
}
|
||||
|
||||
fn save_metadata(&mut self, conn: &Connection) -> Result<()> {
|
||||
if !self.is_saved {
|
||||
if let Some(item_id) = self.item_id {
|
||||
let is_binary_result = is_binary(&self.buffer);
|
||||
let value = if is_binary_result { "true".to_string() } else { "false".to_string() };
|
||||
|
||||
// Save to database immediately using central output handler
|
||||
let _ = self.save_meta(conn, item_id, "binary", value);
|
||||
|
||||
self.is_saved = true;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl MetaPlugin for BinaryMetaPlugin {
|
||||
@@ -82,26 +68,31 @@ impl MetaPlugin for BinaryMetaPlugin {
|
||||
true
|
||||
}
|
||||
|
||||
fn finalize(&mut self) -> Result<MetaPluginResponse> {
|
||||
fn finalize(&mut self) -> MetaPluginResponse {
|
||||
let mut metadata = Vec::new();
|
||||
|
||||
// Save the binary detection result when finalizing, if not already saved
|
||||
if let Some(item_id) = self.item_id {
|
||||
if let Some(_item_id) = self.item_id {
|
||||
let is_binary_result = is_binary(&self.buffer);
|
||||
let value = if is_binary_result { "true".to_string() } else { "false".to_string() };
|
||||
|
||||
if let Some(meta) = self.create_meta(item_id, "binary", value) {
|
||||
metadata.push(meta);
|
||||
// Use process_metadata_outputs to handle output mapping
|
||||
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
||||
"binary",
|
||||
value,
|
||||
&self.outputs
|
||||
) {
|
||||
metadata.push(meta_data);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(MetaPluginResponse {
|
||||
metadata: Some(metadata),
|
||||
MetaPluginResponse {
|
||||
metadata,
|
||||
is_finalized: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn update(&mut self, data: &[u8]) -> Result<MetaPluginResponse> {
|
||||
fn update(&mut self, data: &[u8]) -> MetaPluginResponse {
|
||||
// Calculate how much data we can still accept
|
||||
let remaining_capacity = self.max_buffer_size.saturating_sub(self.buffer.len());
|
||||
if remaining_capacity > 0 {
|
||||
@@ -115,29 +106,36 @@ impl MetaPlugin for BinaryMetaPlugin {
|
||||
// If we've reached our buffer limit, return metadata
|
||||
let mut metadata = Vec::new();
|
||||
if self.buffer.len() >= self.max_buffer_size {
|
||||
if let Some(item_id) = self.item_id {
|
||||
if let Some(_item_id) = self.item_id {
|
||||
let is_binary_result = is_binary(&self.buffer);
|
||||
let value = if is_binary_result { "true".to_string() } else { "false".to_string() };
|
||||
|
||||
if let Some(meta) = self.create_meta(item_id, "binary", value) {
|
||||
metadata.push(meta);
|
||||
// Use process_metadata_outputs to handle output mapping
|
||||
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
||||
"binary",
|
||||
value,
|
||||
&self.outputs
|
||||
) {
|
||||
metadata.push(meta_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(MetaPluginResponse {
|
||||
metadata: if metadata.is_empty() { None } else { Some(metadata) },
|
||||
MetaPluginResponse {
|
||||
metadata,
|
||||
is_finalized: !metadata.is_empty(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn meta_name(&self) -> String {
|
||||
self.meta_name.clone()
|
||||
}
|
||||
|
||||
fn initialize(&mut self, item_id: i64) -> Result<MetaPluginResponse> {
|
||||
self.item_id = Some(item_id);
|
||||
Ok(MetaPluginResponse::default())
|
||||
fn initialize(&mut self) -> MetaPluginResponse {
|
||||
MetaPluginResponse {
|
||||
metadata: Vec::new(),
|
||||
is_finalized: false,
|
||||
}
|
||||
}
|
||||
|
||||
fn configure_options(&mut self, options: &std::collections::HashMap<String, serde_yaml::Value>) -> Result<()> {
|
||||
|
||||
Reference in New Issue
Block a user