From e144810d73745c0f0ab810dba1fa1fa4240059d1 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 5 Nov 2020 10:32:48 +0100 Subject: [PATCH] pxar: more concise EOF handling Signed-off-by: Wolfgang Bumiller --- src/pxar/create.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pxar/create.rs b/src/pxar/create.rs index 6fe820bd..1684a74c 100644 --- a/src/pxar/create.rs +++ b/src/pxar/create.rs @@ -658,6 +658,7 @@ impl<'a, 'b> Archiver<'a, 'b> { let mut out = encoder.create_file(metadata, file_name, file_size)?; while remaining != 0 { let mut got = match file.read(&mut self.file_copy_buffer[..]) { + Ok(0) => break, Ok(got) => got, Err(err) if err.kind() == std::io::ErrorKind::Interrupted => continue, Err(err) => bail!(err), @@ -665,8 +666,6 @@ impl<'a, 'b> Archiver<'a, 'b> { if got as u64 > remaining { self.report_file_grew_while_reading()?; got = remaining as usize; - } else if got == 0 { - break; // we reached eof } out.write_all(&self.file_copy_buffer[..got])?; remaining -= got as u64;