From 4654e8166d8e69bdc4e2a490540d8085195cf9fc Mon Sep 17 00:00:00 2001 From: Tiga Ultraman Date: Wed, 27 Nov 2024 15:31:26 +0800 Subject: [PATCH] Fix Uploader lost progress callbacks Signed-off-by: Tiga Ultraman --- ylong_http_client/src/async_impl/uploader/mod.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ylong_http_client/src/async_impl/uploader/mod.rs b/ylong_http_client/src/async_impl/uploader/mod.rs index 068e042..e527417 100644 --- a/ylong_http_client/src/async_impl/uploader/mod.rs +++ b/ylong_http_client/src/async_impl/uploader/mod.rs @@ -156,8 +156,15 @@ where } Poll::Pending => return Poll::Pending, } - - Pin::new(&mut this.reader).poll_read(cx, buf) + match Pin::new(&mut this.reader).poll_read(cx, buf) { + Poll::Ready(Ok(_)) => { + let filled = buf.filled().len(); + info.uploaded_bytes += filled as u64; + Poll::Ready(Ok(())) + } + Poll::Ready(Err(e)) => Poll::Ready(Err(e)), + Poll::Pending => Poll::Pending, + } } } -- Gitee