fix: remove unused magic_file metadata outputs and fix binary detection timing

Co-authored-by: aider (openai/andrew/openrouter/qwen/qwen3-coder) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-18 11:08:48 -03:00
parent 7f28129c00
commit 2a16edcbe7
2 changed files with 15 additions and 31 deletions

View File

@@ -49,7 +49,20 @@ impl MetaPlugin for BinaryMetaPlugin {
}
fn finalize(&mut self) -> Result<()> {
// Since we save during initialize() or update(), return Ok to avoid duplicate saves
// Save the binary detection result when finalizing, after all data has been collected
if !self.is_saved {
if let (Some(conn), Some(item_id)) = (self.conn, self.item_id) {
// Convert raw pointer back to reference (unsafe)
let conn_ref = unsafe { &*conn };
let is_binary = is_binary(&self.buffer);
let value = if is_binary { "true".to_string() } else { "false".to_string() };
// Save to database immediately using central output handler
let _ = output_metadata(conn_ref, item_id, &self.meta_name, value, &self.output_names);
self.is_saved = true;
}
}
Ok(())
}
@@ -59,21 +72,6 @@ impl MetaPlugin for BinaryMetaPlugin {
if remaining_capacity > 0 {
let bytes_to_copy = std::cmp::min(data.len(), remaining_capacity);
self.buffer.extend_from_slice(&data[..bytes_to_copy]);
// Check if we've reached our buffer limit and save if so
if self.buffer.len() >= self.max_buffer_size && !self.is_saved {
if let (Some(conn), Some(item_id)) = (self.conn, self.item_id) {
// Convert raw pointer back to reference (unsafe)
let conn_ref = unsafe { &*conn };
let is_binary = is_binary(&self.buffer);
let value = if is_binary { "true".to_string() } else { "false".to_string() };
// Save to database immediately using central output handler
let _ = output_metadata(conn_ref, item_id, &self.meta_name, value, &self.output_names);
self.is_saved = true;
}
}
}
}