Skip to content

Commit

Permalink
async deflate test work, it seems
Browse files Browse the repository at this point in the history
  • Loading branch information
fasterthanlime committed Feb 1, 2024
1 parent fe0eb7f commit f91c604
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/reader/tokio/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,16 @@ impl AsyncRead for RawEntryReader {
_cx: &mut task::Context<'_>,
buf: &mut tokio::io::ReadBuf<'_>,
) -> task::Poll<io::Result<()>> {
let len = cmp::min(buf.remaining() as u64, self.remaining) as usize;
let len = cmp::min(
buf.remaining() as u64,
cmp::min(self.remaining, self.inner.available_data() as _),
) as usize;
tracing::trace!(%len, buf_remaining = buf.remaining(), remaining = self.remaining, available_data = self.inner.available_data(), available_space = self.inner.available_space(), "computing len");

buf.put_slice(&self.inner.data()[..len]);
self.as_mut().inner.consume(len);
self.remaining -= len as u64;

Ok(()).into()
}
}

0 comments on commit f91c604

Please sign in to comment.