src/client/http_client.rs - download_chunk_list: simplify async code

This commit is contained in:
Dietmar Maurer 2019-09-05 14:16:45 +02:00
parent 44f59dc731
commit c18fddf80f

View File

@ -851,14 +851,15 @@ impl BackupClient {
let mut body = resp.into_body(); let mut body = resp.into_body();
let mut release_capacity = body.release_capacity().clone(); let mut release_capacity = body.release_capacity().clone();
DigestListDecoder::new(body.map_err(Error::from)) let mut stream = DigestListDecoder::new(body.map_err(Error::from));
.try_for_each(move |chunk| {
let _ = release_capacity.release_capacity(chunk.len()); while let Some(chunk) = stream.try_next().await? {
println!("GOT DOWNLOAD {}", digest_to_hex(&chunk)); let _ = release_capacity.release_capacity(chunk.len());
known_chunks.lock().unwrap().insert(chunk); println!("GOT DOWNLOAD {}", digest_to_hex(&chunk));
futures::future::ok(()) known_chunks.lock().unwrap().insert(chunk);
}) }
.await
Ok(())
} }
fn upload_chunk_info_stream( fn upload_chunk_info_stream(