From a69cae22dd91580080ffbba17b1f15e37943c2e2 Mon Sep 17 00:00:00 2001 From: J H <2364004+Blu-J@users.noreply.github.com> Date: Mon, 23 Oct 2023 14:41:54 -0600 Subject: [PATCH] chore: Cleaning up the stream to a regular stream (#2468) --- backend/src/procedure/docker.rs | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/backend/src/procedure/docker.rs b/backend/src/procedure/docker.rs index 92d19d6c2..463b2f2e4 100644 --- a/backend/src/procedure/docker.rs +++ b/backend/src/procedure/docker.rs @@ -892,22 +892,13 @@ async fn buf_reader_to_lines( reader: impl AsyncBufRead + Unpin, limit: impl Into>, ) -> Result, Error> { - let lines = stream! { - let mut lines = reader.lines(); - while let Some(line) = lines.next_line().await? { - yield Ok::<_, Report>(line); + let mut lines = reader.lines(); + let mut output = RingVec::new(limit.into().unwrap_or(1000)); + while let Ok(line) = lines.next_line().await { + if let Some(line) = line { + output.push(line); } - }; - let output: RingVec = lines - .try_fold( - RingVec::new(limit.into().unwrap_or(1000)), - |mut acc, line| async move { - acc.push(line); - Ok(acc) - }, - ) - .await - .with_kind(crate::ErrorKind::Unknown)?; + } let output: Vec = output.value.into_iter().collect(); Ok(output) }