Skip to content

Commit

Permalink
Merge branch 'bugfix/output-timeout' of github.com:Start9Labs/start-o…
Browse files Browse the repository at this point in the history
…s into bugfix/output-timeout
  • Loading branch information
dr-bonez committed Oct 24, 2023
2 parents 015c48e + 89150d8 commit c6569f8
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions backend/src/procedure/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -893,13 +893,11 @@ async fn buf_reader_to_lines(
limit: impl Into<Option<usize>>,
) -> Result<Vec<String>, Error> {
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 mut answer = RingVec::new(limit.into().unwrap_or(1000));
while let Some(line) = lines.next_line().await? {
answer.push(line);
}
let output: Vec<String> = output.value.into_iter().collect();
let output: Vec<String> = answer.value.into_iter().collect();
Ok(output)
}

Expand Down Expand Up @@ -964,4 +962,11 @@ mod tests {
assert_eq!(CAPACITY_IN, ring.value.capacity());
assert_eq!(CAPACITY_IN, ring.value.len());
}

#[test]
fn tests_buf_reader_to_lines() {
let mut reader = BufReader::new("hello\nworld\n".as_bytes());
let lines = futures::executor::block_on(buf_reader_to_lines(&mut reader, None)).unwrap();
assert_eq!(lines, vec!["hello", "world"]);
}
}

0 comments on commit c6569f8

Please sign in to comment.