Compare commits
No commits in common. "b1797dafd2a9da4724de4b01eacf2c6e37f8f721" and "5338ff81a58482528d77f6a9468e836768a9c34f" have entirely different histories.
b1797dafd2
...
5338ff81a5
1 changed files with 21 additions and 18 deletions
39
src/cache/fs.rs
vendored
39
src/cache/fs.rs
vendored
|
@ -158,11 +158,10 @@ impl<R: AsyncRead> AsyncRead for EncryptedReader<R> {
|
|||
cx: &mut Context<'_>,
|
||||
buf: &mut ReadBuf<'_>,
|
||||
) -> Poll<std::io::Result<()>> {
|
||||
let mut pinned = self.as_mut();
|
||||
let previously_read = buf.filled().len();
|
||||
let res = pinned.file.as_mut().poll_read(cx, buf);
|
||||
let res = self.as_mut().file.as_mut().poll_read(cx, buf);
|
||||
let bytes_modified = buf.filled().len() - previously_read;
|
||||
pinned.keystream.apply_keystream(
|
||||
self.keystream.apply_keystream(
|
||||
&mut buf.filled_mut()[previously_read..previously_read + bytes_modified],
|
||||
);
|
||||
res
|
||||
|
@ -215,7 +214,7 @@ impl<'a, R: AsyncBufRead> Future for MetadataFuture<'a, R> {
|
|||
|
||||
// This needs to be outside the loop because we need to drop the
|
||||
// reader ref, since that depends on a mut self.
|
||||
pinned.as_mut().consume(bytes_consumed);
|
||||
pinned.as_mut().consume(dbg!(bytes_consumed));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
@ -327,27 +326,31 @@ impl AsyncWrite for EncryptedDiskWriter {
|
|||
Poll::Ready(Ok(buf.len()))
|
||||
}
|
||||
Poll::Ready(Err(e)) => Poll::Ready(Err(e)),
|
||||
// We have written the data to our buffer, even if we haven't
|
||||
// couldn't write the file to disk.
|
||||
Poll::Pending => Poll::Ready(Ok(buf.len())),
|
||||
Poll::Pending => Poll::Pending,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), std::io::Error>> {
|
||||
let pinned = Pin::into_inner(self);
|
||||
|
||||
while !pinned.buffer.is_empty() {
|
||||
match pinned.file.as_mut().poll_write(cx, &pinned.buffer) {
|
||||
Poll::Ready(Ok(n)) => {
|
||||
pinned.buffer.drain(..n);
|
||||
fn poll_flush(
|
||||
mut self: Pin<&mut Self>,
|
||||
cx: &mut Context<'_>,
|
||||
) -> Poll<Result<(), std::io::Error>> {
|
||||
if self.buffer.is_empty() {
|
||||
self.as_mut().file.as_mut().poll_flush(cx)
|
||||
} else {
|
||||
let pinned = Pin::into_inner(self);
|
||||
while !pinned.buffer.is_empty() {
|
||||
match pinned.file.as_mut().poll_write(cx, &pinned.buffer) {
|
||||
Poll::Ready(Ok(n)) => {
|
||||
pinned.buffer.drain(..n);
|
||||
}
|
||||
Poll::Ready(Err(e)) => return Poll::Ready(Err(e)),
|
||||
Poll::Pending => return Poll::Pending,
|
||||
}
|
||||
Poll::Ready(Err(e)) => return Poll::Ready(Err(e)),
|
||||
Poll::Pending => return Poll::Pending,
|
||||
}
|
||||
}
|
||||
|
||||
pinned.file.as_mut().poll_flush(cx)
|
||||
Poll::Ready(Ok(()))
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
Loading…
Reference in a new issue