Simplify DiskWriter poll_flush
This commit is contained in:
parent
5338ff81a5
commit
9209b822a9
1 changed files with 12 additions and 18 deletions
12
src/cache/fs.rs
vendored
12
src/cache/fs.rs
vendored
|
@ -331,14 +331,9 @@ impl AsyncWrite for EncryptedDiskWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn poll_flush(
|
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), std::io::Error>> {
|
||||||
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);
|
let pinned = Pin::into_inner(self);
|
||||||
|
|
||||||
while !pinned.buffer.is_empty() {
|
while !pinned.buffer.is_empty() {
|
||||||
match pinned.file.as_mut().poll_write(cx, &pinned.buffer) {
|
match pinned.file.as_mut().poll_write(cx, &pinned.buffer) {
|
||||||
Poll::Ready(Ok(n)) => {
|
Poll::Ready(Ok(n)) => {
|
||||||
|
@ -349,8 +344,7 @@ impl AsyncWrite for EncryptedDiskWriter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Poll::Ready(Ok(()))
|
pinned.file.as_mut().poll_flush(cx)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
Loading…
Reference in a new issue