Skip to content

Commit 09a87db

Browse files
committed
add panicked flag to BzDecoder
1 parent b4a143b commit 09a87db

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/write.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub struct BzDecoder<W: Write> {
2222
obj: Option<W>,
2323
buf: Vec<u8>,
2424
done: bool,
25+
panicked: bool,
2526
}
2627

2728
impl<W: Write> BzEncoder<W> {
@@ -167,6 +168,7 @@ impl<W: Write> BzDecoder<W> {
167168
obj: Some(obj),
168169
buf: Vec::with_capacity(32 * 1024),
169170
done: false,
171+
panicked: false,
170172
}
171173
}
172174

@@ -185,12 +187,15 @@ impl<W: Write> BzDecoder<W> {
185187

186188
fn dump(&mut self) -> io::Result<()> {
187189
while !self.buf.is_empty() {
188-
let n = match self.obj.as_mut().unwrap().write(&self.buf) {
189-
Ok(n) => n,
190+
self.panicked = true;
191+
let r = self.obj.as_mut().unwrap().write(&self.buf);
192+
self.panicked = false;
193+
194+
match r {
195+
Ok(n) => self.buf.drain(..n),
190196
Err(ref err) if err.kind() == io::ErrorKind::Interrupted => continue,
191197
Err(err) => return Err(err),
192198
};
193-
self.buf.drain(..n);
194199
}
195200
Ok(())
196201
}

0 commit comments

Comments
 (0)