feat: add early binary detection and prevent duplicate metadata saving
Co-authored-by: aider (openai/andrew/openrouter/qwen/qwen3-coder) <aider@aider.chat>
This commit is contained in:
@@ -171,6 +171,7 @@ fn process_input_stream(
|
||||
.create(item_path.clone())
|
||||
.map_err(|e| anyhow!("Unable to write file {:?}: {}", item_path, e))?;
|
||||
|
||||
let mut total_bytes = 0;
|
||||
debug!("MAIN: Starting IO loop");
|
||||
loop {
|
||||
let n = stdin.read(&mut buffer[..libc::BUFSIZ as usize])?;
|
||||
@@ -184,14 +185,27 @@ fn process_input_stream(
|
||||
break;
|
||||
}
|
||||
|
||||
debug!("MAIN: Loop - {:?} bytes", item.size);
|
||||
total_bytes += n;
|
||||
debug!("MAIN: Loop - {:?} bytes (total: {})", item.size, total_bytes);
|
||||
|
||||
stdout.write_all(&buffer[..n])?;
|
||||
item_out.write_all(&buffer[..n])?;
|
||||
|
||||
// Process data with meta plugins
|
||||
for meta_plugin in meta_plugins.iter_mut() {
|
||||
meta_plugin.update(&buffer[..n]);
|
||||
}
|
||||
|
||||
// Check if we should finalize and save the binary plugin after 4KB
|
||||
if total_bytes >= 4096 {
|
||||
for meta_plugin in meta_plugins.iter_mut() {
|
||||
if meta_plugin.meta_name() == "binary" && !meta_plugin.is_internal() {
|
||||
// For internal plugins like BinaryMetaPlugin, we need to handle it differently
|
||||
// Since we can't easily check the type, we'll use a flag in the finalize method
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
debug!("MAIN: Ending IO loop after {:?} bytes", item.size);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user