diff --git a/core/src/raw/oio/read/buffer_reader.rs b/core/src/raw/oio/read/buffer_reader.rs index ec212d66e3b9..d6d723fa7bb4 100644 --- a/core/src/raw/oio/read/buffer_reader.rs +++ b/core/src/raw/oio/read/buffer_reader.rs @@ -450,29 +450,29 @@ mod tests { let mut r = Reader::new(r); // The underlying reader buffers the b"Hello, Wor". - let bs = r.read(5).await?; - assert_eq!(bs.len(), 5); - assert_eq!(bs.as_ref(), b"Hello"); + let buf = r.read(5).await?; + assert_eq!(buf.len(), 5); + assert_eq!(buf.as_ref(), b"Hello"); let pos = r.seek(SeekFrom::Start(7)).await?; assert_eq!(pos, 7); - let bs = r.read(5).await?; - assert_eq!(&bs, &bs[7..10]); - assert_eq!(bs.len(), 3); + let buf = r.read(5).await?; + assert_eq!(&buf, &bs[7..10]); + assert_eq!(buf.len(), 3); // Should perform a relative seek. let pos = r.seek(SeekFrom::Start(0)).await?; assert_eq!(pos, 0); - let bs = r.read(9).await?; - assert_eq!(&bs, &bs[0..9]); - assert_eq!(bs.len(), 9); + let buf = r.read(9).await?; + assert_eq!(&buf, &bs[0..9]); + assert_eq!(buf.len(), 9); // Should perform a non-relative seek. let pos = r.seek(SeekFrom::Start(11)).await?; assert_eq!(pos, 11); - let bs = r.read(9).await?; - assert_eq!(&bs, &bs[11..13]); - assert_eq!(bs.len(), 2); + let buf = r.read(9).await?; + assert_eq!(&buf, &bs[11..13]); + assert_eq!(buf.len(), 2); Ok(()) } diff --git a/core/src/types/reader.rs b/core/src/types/reader.rs index 57754456805b..768db3e17a88 100644 --- a/core/src/types/reader.rs +++ b/core/src/types/reader.rs @@ -190,7 +190,7 @@ impl Reader { match self.read(read_buf.initialize_unfilled().len()).await { Ok(bs) if bs.is_empty() => { - return Ok(bs.len() - start_len); + return Ok(buf.len() - start_len); } Ok(bs) => { read_buf.initialize_unfilled()[..bs.len()].copy_from_slice(&bs);