Skip to content

Commit 5bb81d0

Browse files
fix: Fix reported upload total bytes
1 parent c6926cc commit 5bb81d0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

plugins/upload/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ async fn upload(
138138
let mut request = client
139139
.post(&url)
140140
.header(reqwest::header::CONTENT_LENGTH, file_len)
141-
.body(file_to_body(on_progress, file));
141+
.body(file_to_body(on_progress, file, file_len));
142142

143143
// Loop through the headers keys and values
144144
// and add them to the request object.
@@ -160,18 +160,18 @@ async fn upload(
160160
.map_err(|e| Error::Io(std::io::Error::new(std::io::ErrorKind::Other, e.to_string())))?
161161
}
162162

163-
fn file_to_body(channel: Channel<ProgressPayload>, file: File) -> reqwest::Body {
163+
fn file_to_body(channel: Channel<ProgressPayload>, file: File, file_len: u64) -> reqwest::Body {
164164
let stream = FramedRead::new(file, BytesCodec::new()).map_ok(|r| r.freeze());
165165

166166
let mut stats = TransferStats::default();
167167
reqwest::Body::wrap_stream(ReadProgressStream::new(
168168
stream,
169-
Box::new(move |progress, total| {
169+
Box::new(move |progress, _total| {
170170
stats.record_chunk_transfer(progress as usize);
171171
let _ = channel.send(ProgressPayload {
172172
progress,
173173
progress_total: stats.total_transferred,
174-
total,
174+
total: file_len,
175175
transfer_speed: stats.transfer_speed,
176176
});
177177
}),

0 commit comments

Comments
 (0)