fix: correctly track and log item size during IO loop
This commit is contained in:
committed by
Andrew Phillips (aider)
parent
00572135ec
commit
0bf898c0e7
0
src/meta_plugin/digest.rs
Normal file
0
src/meta_plugin/digest.rs
Normal file
@@ -132,12 +132,18 @@ pub fn mode_save(
|
|||||||
debug!("MAIN: Starting IO loop");
|
debug!("MAIN: Starting IO loop");
|
||||||
loop {
|
loop {
|
||||||
let n = stdin.read(&mut buffer[..libc::BUFSIZ as usize])?;
|
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 {
|
if n == 0 {
|
||||||
debug!("MAIN: EOF on STDIN");
|
debug!("MAIN: EOF on STDIN");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debug!("MAIN: Loop - {:?} bytes", item.size);
|
||||||
|
|
||||||
stdout.write_all(&buffer[..n])?;
|
stdout.write_all(&buffer[..n])?;
|
||||||
item_out.write_all(&buffer[..n])?;
|
item_out.write_all(&buffer[..n])?;
|
||||||
digest_engine.update(&buffer[..n]);
|
digest_engine.update(&buffer[..n]);
|
||||||
@@ -145,13 +151,8 @@ pub fn mode_save(
|
|||||||
for meta_plugin in meta_plugins.iter_mut() {
|
for meta_plugin in meta_plugins.iter_mut() {
|
||||||
meta_plugin.update(&buffer[..n]);
|
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()?;
|
stdout.flush()?;
|
||||||
item_out.flush()?;
|
item_out.flush()?;
|
||||||
|
|||||||
Reference in New Issue
Block a user