]> git.nihav.org Git - nihav.git/commitdiff
core/io: hopefully fix BoundedFileReader::read_buf_some() for good
authorKostya Shishkov <kostya.shishkov@gmail.com>
Thu, 18 Nov 2021 15:04:59 +0000 (16:04 +0100)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Thu, 18 Nov 2021 15:04:59 +0000 (16:04 +0100)
nihav-core/src/io/byteio.rs

index 2bac1900967b74545e411ccf0d8c5f886c07c775..0ff54cb13ed9321e31f794dbea03e8365d53dc39 100644 (file)
@@ -753,14 +753,13 @@ impl<T: Read+Seek> ByteIO for BoundedFileReader<T> {
         if ret.is_err() { return Err(ByteIOError::ReadError); }
         let sz = ret.unwrap();
         if sz < len {
-            if let Err(_err) = self.file.read(&mut buf[sz..][..1]) {
-                self.eof = true;
-                if sz == 0 {
-                    return Err(ByteIOError::EOF);
-                }
-            } else {
+            if let Ok(1) = self.file.read(&mut buf[sz..][..1]) {
                 return Ok(sz + 1);
             }
+            self.eof = true;
+            if sz == 0 {
+                return Err(ByteIOError::EOF);
+            }
         }
         Ok(sz)
     }