Skip to content

Commit

Permalink
chore: Cleaning up the stream to a regular stream (#2468)
Browse files Browse the repository at this point in the history
  • Loading branch information
Blu-J authored Oct 23, 2023
1 parent 8ea3c3c commit a69cae2
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions backend/src/procedure/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -892,22 +892,13 @@ async fn buf_reader_to_lines(
reader: impl AsyncBufRead + Unpin,
limit: impl Into<Option<usize>>,
) -> Result<Vec<String>, 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<String> = 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<String> = output.value.into_iter().collect();
Ok(output)
}
Expand Down

0 comments on commit a69cae2

Please sign in to comment.