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,6 +1,7 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
pub mod program;
|
pub mod program;
|
||||||
pub mod digest;
|
pub mod digest;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use rusqlite::Connection;
|
use rusqlite::Connection;
|
||||||
|
|
||||||
use crate::common::is_binary::is_binary;
|
use crate::common::is_binary::is_binary;
|
||||||
use crate::common::PIPESIZE;
|
use crate::common::PIPESIZE;
|
||||||
use crate::meta_plugin::MetaPlugin;
|
use crate::meta_plugin::{MetaPlugin, MetaPluginResponse, MetaData};
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default)]
|
#[derive(Debug, Clone, Default)]
|
||||||
pub struct BinaryMetaPlugin {
|
pub struct BinaryMetaPlugin {
|
||||||
@@ -61,20 +61,6 @@ impl BinaryMetaPlugin {
|
|||||||
Self::new(None, None)
|
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 {
|
impl MetaPlugin for BinaryMetaPlugin {
|
||||||
@@ -82,26 +68,31 @@ impl MetaPlugin for BinaryMetaPlugin {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn finalize(&mut self) -> Result<MetaPluginResponse> {
|
fn finalize(&mut self) -> MetaPluginResponse {
|
||||||
let mut metadata = Vec::new();
|
let mut metadata = Vec::new();
|
||||||
|
|
||||||
// Save the binary detection result when finalizing, if not already saved
|
// 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 is_binary_result = is_binary(&self.buffer);
|
||||||
let value = if is_binary_result { "true".to_string() } else { "false".to_string() };
|
let value = if is_binary_result { "true".to_string() } else { "false".to_string() };
|
||||||
|
|
||||||
if let Some(meta) = self.create_meta(item_id, "binary", value) {
|
// Use process_metadata_outputs to handle output mapping
|
||||||
metadata.push(meta);
|
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
||||||
|
"binary",
|
||||||
|
value,
|
||||||
|
&self.outputs
|
||||||
|
) {
|
||||||
|
metadata.push(meta_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(MetaPluginResponse {
|
MetaPluginResponse {
|
||||||
metadata: Some(metadata),
|
metadata,
|
||||||
is_finalized: true,
|
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
|
// Calculate how much data we can still accept
|
||||||
let remaining_capacity = self.max_buffer_size.saturating_sub(self.buffer.len());
|
let remaining_capacity = self.max_buffer_size.saturating_sub(self.buffer.len());
|
||||||
if remaining_capacity > 0 {
|
if remaining_capacity > 0 {
|
||||||
@@ -115,29 +106,36 @@ impl MetaPlugin for BinaryMetaPlugin {
|
|||||||
// If we've reached our buffer limit, return metadata
|
// If we've reached our buffer limit, return metadata
|
||||||
let mut metadata = Vec::new();
|
let mut metadata = Vec::new();
|
||||||
if self.buffer.len() >= self.max_buffer_size {
|
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 is_binary_result = is_binary(&self.buffer);
|
||||||
let value = if is_binary_result { "true".to_string() } else { "false".to_string() };
|
let value = if is_binary_result { "true".to_string() } else { "false".to_string() };
|
||||||
|
|
||||||
if let Some(meta) = self.create_meta(item_id, "binary", value) {
|
// Use process_metadata_outputs to handle output mapping
|
||||||
metadata.push(meta);
|
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
||||||
|
"binary",
|
||||||
|
value,
|
||||||
|
&self.outputs
|
||||||
|
) {
|
||||||
|
metadata.push(meta_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(MetaPluginResponse {
|
MetaPluginResponse {
|
||||||
metadata: if metadata.is_empty() { None } else { Some(metadata) },
|
metadata,
|
||||||
is_finalized: !metadata.is_empty(),
|
is_finalized: !metadata.is_empty(),
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn meta_name(&self) -> String {
|
fn meta_name(&self) -> String {
|
||||||
self.meta_name.clone()
|
self.meta_name.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn initialize(&mut self, item_id: i64) -> Result<MetaPluginResponse> {
|
fn initialize(&mut self) -> MetaPluginResponse {
|
||||||
self.item_id = Some(item_id);
|
MetaPluginResponse {
|
||||||
Ok(MetaPluginResponse::default())
|
metadata: Vec::new(),
|
||||||
|
is_finalized: false,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn configure_options(&mut self, options: &std::collections::HashMap<String, serde_yaml::Value>) -> Result<()> {
|
fn configure_options(&mut self, options: &std::collections::HashMap<String, serde_yaml::Value>) -> Result<()> {
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use gethostname::gethostname;
|
use gethostname::gethostname;
|
||||||
use local_ip_address::local_ip;
|
|
||||||
use dns_lookup::lookup_addr;
|
|
||||||
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_user_by_uid, get_group_by_gid};
|
||||||
use rusqlite::Connection;
|
use crate::meta_plugin::{MetaPlugin, MetaPluginResponse, MetaData};
|
||||||
|
use std::collections::HashMap;
|
||||||
use crate::meta_plugin::MetaPlugin;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default)]
|
#[derive(Debug, Clone, Default)]
|
||||||
pub struct CwdMetaPlugin {
|
pub struct CwdMetaPlugin {
|
||||||
|
|||||||
Reference in New Issue
Block a user