File tree Expand file tree Collapse file tree 1 file changed +10
-14
lines changed
Expand file tree Collapse file tree 1 file changed +10
-14
lines changed Original file line number Diff line number Diff line change @@ -231,22 +231,18 @@ fn copy(mut input: impl Read, mut output: impl Write) -> Result<usize> {
231231 let mut len = 0 ;
232232
233233 loop {
234- let received = match input. read ( & mut buffer) {
235- Ok ( bytes_count) => bytes_count,
236- Err ( e) if e. kind ( ) == ErrorKind :: Interrupted => continue ,
234+ match input. read ( & mut buffer) {
235+ Ok ( 0 ) => return Ok ( len) , // end of file
236+ Ok ( received) => {
237+ output. write_all ( & buffer[ ..received] ) ?;
238+ // flush the buffer to comply with POSIX requirement that
239+ // `tee` does not buffer the input.
240+ output. flush ( ) ?;
241+ len += received;
242+ }
243+ Err ( e) if e. kind ( ) == ErrorKind :: Interrupted => { }
237244 Err ( e) => return Err ( e) ,
238- } ;
239-
240- if received == 0 {
241- return Ok ( len) ;
242245 }
243-
244- output. write_all ( & buffer[ 0 ..received] ) ?;
245-
246- // We need to flush the buffer here to comply with POSIX requirement that
247- // `tee` does not buffer the input.
248- output. flush ( ) ?;
249- len += received;
250246 }
251247}
252248
You can’t perform that action at this time.
0 commit comments