Skip to content

Commit 6566a1d

Browse files
authored
fix(storage-w1r3): make download() correctly return transfer_size (#5133)
Previously `read_data` was created using `move`. Since `transfer_size` is a `usize` which is `Copy`, `read_data` received its own copy of `transfer_size`. As the original `transfer_size` was never updated, `download()` always returned `0`.
1 parent e3c0870 commit 6566a1d

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

  • src/storage/benchmarks/w1r3/src

src/storage/benchmarks/w1r3/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,9 @@ async fn download(
333333
}
334334
};
335335
read_done();
336+
336337
let mut transfer_size = 0;
337-
let mut read_data = async move || {
338+
let read_data = async {
338339
while let Some(result) = read.next().await {
339340
match result {
340341
Ok(b) => transfer_size += b.len(),
@@ -346,8 +347,7 @@ async fn download(
346347
}
347348
Ok(())
348349
};
349-
350-
match tokio::time::timeout(timeout, Instrumented::new(read_data())).await {
350+
match tokio::time::timeout(timeout, Instrumented::new(read_data)).await {
351351
Err(e) => (transfer_size, Err(google_cloud_storage::Error::timeout(e))),
352352
Ok(r) => (transfer_size, r),
353353
}

0 commit comments

Comments
 (0)