diff --git a/src/walk.rs b/src/walk.rs index c6737ed..c81d2a4 100644 --- a/src/walk.rs +++ b/src/walk.rs @@ -214,7 +214,6 @@ impl<'a, W: Write> ReceiverBuffer<'a, W> { } ReceiverMode::Streaming => { self.print(&dir_entry)?; - self.flush()?; } } @@ -232,6 +231,11 @@ impl<'a, W: Write> ReceiverBuffer<'a, W> { } } } + + // If we don't have another batch ready, flush before waiting + if self.mode == ReceiverMode::Streaming && self.rx.is_empty() { + self.flush()?; + } } Err(RecvTimeoutError::Timeout) => { self.stream()?; @@ -285,7 +289,7 @@ impl<'a, W: Write> ReceiverBuffer<'a, W> { /// Flush stdout if necessary. fn flush(&mut self) -> Result<(), ExitCode> { - if self.config.interactive_terminal && self.stdout.flush().is_err() { + if self.stdout.flush().is_err() { // Probably a broken pipe. Exit gracefully. return Err(ExitCode::GeneralError); }