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:
Andrew Phillips
2025-08-26 18:01:37 -03:00
parent e2b434e52c
commit 9751e7074c
3 changed files with 8 additions and 20 deletions

View File

@@ -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();
}
}