Skip to content

Commit

Permalink
handle using padding after chunk
Browse files Browse the repository at this point in the history
  • Loading branch information
james-rms committed Dec 20, 2024
1 parent 5f520bd commit 849d60b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions rust/src/sans_io/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,12 +581,19 @@ impl LinearReader {
hasher.update(opcode_len_data);
}
state.compressed_remaining -= (9 + len) as u64;
state.uncompressed_remaining -= (9 + len) as u64;
return Some(Ok(ReadAction::GetRecord { data, opcode }));
} else {
if self.decompressed_content.len() == 0 {
self.decompressed_content.clear();
}
if state.compressed_remaining == 0 && self.decompressed_content.len() == 0 {
if state.uncompressed_remaining == 0 && self.decompressed_content.len() == 0
{
// Some compressed data regions will have padding inserted at the end by
// the compressor, which we need to skip now that we have all the data we
// need.
state.padding_after_compressed_data +=
check!(len_as_usize(state.compressed_remaining));
self.currently_reading = PaddingAfterChunk;
continue;
}
Expand Down Expand Up @@ -1101,7 +1108,9 @@ mod tests {
let mut f = std::fs::File::open("tests/data/break_zstd_decompression.mcap")
.expect("failed to open file");
let blocksize: usize = 1024;
let mut reader = LinearReader::new();
let mut reader = LinearReader::new_with_options(
LinearReaderOptions::default().with_prevalidate_chunk_crcs(true),
);
while let Some(action) = reader.next_action() {
match action.expect("failed to get next action") {
ReadAction::GetRecord { data: _, opcode } => {
Expand Down

0 comments on commit 849d60b

Please sign in to comment.