fix: correctly track and log item size during IO loop

This commit is contained in:
Andrew Phillips
2025-07-28 17:12:10 -03:00
committed by Andrew Phillips (aider)
parent 00572135ec
commit 0bf898c0e7
2 changed files with 7 additions and 6 deletions

View File

@@ -132,12 +132,18 @@ pub fn mode_save(
debug!("MAIN: Starting IO loop");
loop {
let n = stdin.read(&mut buffer[..libc::BUFSIZ as usize])?;
item.size = match item.size {
None => Some(n as i64),
Some(prev_n) => Some(prev_n + n as i64),
};
if n == 0 {
debug!("MAIN: EOF on STDIN");
break;
}
debug!("MAIN: Loop - {:?} bytes", item.size);
stdout.write_all(&buffer[..n])?;
item_out.write_all(&buffer[..n])?;
digest_engine.update(&buffer[..n]);
@@ -145,13 +151,8 @@ pub fn mode_save(
for meta_plugin in meta_plugins.iter_mut() {
meta_plugin.update(&buffer[..n]);
}
item.size = match item.size {
None => Some(n as i64),
Some(prev_n) => Some(prev_n + n as i64),
};
}
debug!("MAIN: Ending IO loop");
debug!("MAIN: Ending IO loop after {:?} bytes", item.size);
stdout.flush()?;
item_out.flush()?;