]> Humopery - polarsbop.git/commitdiff
simplify file streaming write
authorErik Mackdanz <erikmack@gmail.com>
Wed, 29 Nov 2023 09:17:36 +0000 (03:17 -0600)
committerErik Mackdanz <erikmack@gmail.com>
Wed, 29 Nov 2023 09:17:36 +0000 (03:17 -0600)
src/main.rs

index 2114bf3acc2ff2f699880b578fce64152ec578f8..1f40f7d707091292924259410cd8495f80bbe279 100644 (file)
@@ -163,14 +163,8 @@ async fn reduce_bucket(bucket: &str) -> Result<(),Box<dyn Error>> {
        // 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)?;
        }
     }