Skip to content

Commit

Permalink
Peek buffer needs to actually have space
Browse files Browse the repository at this point in the history
  • Loading branch information
mobiusklein committed Sep 9, 2023
1 parent 5587d1c commit 223c72d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/io/mzml/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1895,6 +1895,7 @@ impl<R: SeekRead, C: CentroidPeakAdapting, D: DeconvolutedPeakAdapting> MzMLRead
self.handle.seek(SeekFrom::Start(offset)).expect("Failed to seek to the index offset");
let mut indexer_state = IndexParserState::Start;
let mut peek_buffer = Bytes::with_capacity(500);
peek_buffer.fill(0);
self.handle.read_exact(&mut peek_buffer).unwrap();
debug!("Peeked: {} buffer of size {}", String::from_utf8_lossy(&peek_buffer), peek_buffer.len());
self.handle.seek(SeekFrom::Start(offset)).expect("Failed to seek to the index offset");
Expand Down Expand Up @@ -2221,8 +2222,7 @@ mod test {
match reader.read_index_from_end() {
Ok(_count) => {}
Err(err) => {
debug!("Failed to parse out index {:?}", err);
assert!(err.to_string() == "");
panic!("Failed to parse out index {:?}", err);
}
};
assert!(reader.index.len() > 0);
Expand Down

0 comments on commit 223c72d

Please sign in to comment.