fix: remove item_id parameter from MetaPlugin methods and update implementations
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -93,7 +93,7 @@ impl MagicFileMetaPlugin {
|
||||
}
|
||||
|
||||
/// Helper function to process all magic types and collect metadata
|
||||
fn process_magic_types(&self, item_id: i64) -> Vec<crate::meta_plugin::MetaData> {
|
||||
fn process_magic_types(&self) -> Vec<crate::meta_plugin::MetaData> {
|
||||
let mut metadata = Vec::new();
|
||||
|
||||
// Define the types to process with their corresponding flags
|
||||
@@ -103,7 +103,7 @@ impl MagicFileMetaPlugin {
|
||||
("file_type", CookieFlags::default()),
|
||||
];
|
||||
|
||||
for (name, flags) in types_to_process {
|
||||
for (name, flags) & types_to_process {
|
||||
if let Ok(result) = self.get_magic_result(flags) {
|
||||
if !result.is_empty() {
|
||||
// Use process_metadata_outputs to handle output mapping
|
||||
@@ -124,9 +124,7 @@ impl MagicFileMetaPlugin {
|
||||
|
||||
impl MetaPlugin for MagicFileMetaPlugin {
|
||||
|
||||
fn initialize(&mut self, item_id: i64) -> crate::meta_plugin::MetaPluginResponse {
|
||||
self.item_id = Some(item_id);
|
||||
|
||||
fn initialize(&mut self) -> crate::meta_plugin::MetaPluginResponse {
|
||||
// Initialize the magic cookie once
|
||||
let cookie = match Cookie::open(Default::default()) {
|
||||
Ok(cookie) => cookie,
|
||||
@@ -152,11 +150,7 @@ impl MetaPlugin for MagicFileMetaPlugin {
|
||||
}
|
||||
|
||||
fn finalize(&mut self) -> crate::meta_plugin::MetaPluginResponse {
|
||||
let metadata = if let Some(item_id) = self.item_id {
|
||||
self.process_magic_types(item_id)
|
||||
} else {
|
||||
Vec::new()
|
||||
};
|
||||
let metadata = self.process_magic_types();
|
||||
|
||||
crate::meta_plugin::MetaPluginResponse {
|
||||
metadata,
|
||||
@@ -175,9 +169,7 @@ impl MetaPlugin for MagicFileMetaPlugin {
|
||||
|
||||
// Check if we've reached our buffer limit and return metadata
|
||||
if self.buffer.len() >= self.max_buffer_size {
|
||||
if let Some(item_id) = self.item_id {
|
||||
metadata = self.process_magic_types(item_id);
|
||||
}
|
||||
metadata = self.process_magic_types();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,8 @@ use log::*;
|
||||
use std::io::Write;
|
||||
use std::process::{Command, Stdio, Child};
|
||||
use which::which;
|
||||
use rusqlite::Connection;
|
||||
|
||||
use crate::meta_plugin::MetaPlugin;
|
||||
use crate::meta_plugin::{MetaPlugin, MetaData};
|
||||
|
||||
pub struct MetaPluginProgram {
|
||||
pub program: String,
|
||||
@@ -164,7 +163,7 @@ impl MetaPlugin for MetaPluginProgram {
|
||||
self.result = Some(result);
|
||||
|
||||
// Create metadata to be returned
|
||||
metadata.push(MetaData {
|
||||
metadata.push(crate::meta_plugin::MetaData {
|
||||
name: self.meta_name.clone(),
|
||||
value: result,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user