From cd8e2b8c50db183846c8ef1cfc786e93c337c715 Mon Sep 17 00:00:00 2001 From: Erik Mackdanz Date: Wed, 29 Nov 2023 03:17:36 -0600 Subject: [PATCH] simplify file streaming write --- src/main.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2114bf3..1f40f7d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -163,14 +163,8 @@ async fn reduce_bucket(bucket: &str) -> Result<(),Box> { // stream body to local filesystem // https://docs.aws.amazon.com/sdk-for-rust/latest/dg/rust_s3_code_examples.html let mut body = getobjresult.body; - loop { - let bytes = body.try_next().await?; - - if let Some(b) = bytes { - let _ = downloadfile.write(&b)?; - } else { - break; - } + while let Some(bytes) = body.try_next().await? { + downloadfile.write(&bytes)?; } } -- 2.52.0