Skip to content

Commit

Permalink
Add comment explaining fdeflate fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
fintelia committed Dec 31, 2022
1 parent f0ef6fd commit 1144b3d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ include = [
[dependencies]
bitflags = "1.0"
crc32fast = "1.2.0"
fdeflate = "0.2.0"
fdeflate = "0.2.1"
flate2 = "1.0"
miniz_oxide = "0.6.0"

Expand Down
7 changes: 5 additions & 2 deletions src/decoder/zlib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ impl Compressor {
(TINFLStatus::HasMoreOutput, in_consumed, out_consumed)
}
Err(fdeflate::DecompressionError::NotFDeflate) => {
*self = Compressor::FullZlib(DecompressorOxide::new());

// fdeflate guarantees that it will detect non-fdeflate streams before
// consuming any input. If that happens, sanity check that no output
// has been produced and feed the same input to a full zlib decoder.
assert_eq!(output_position, 0);

*self = Compressor::FullZlib(DecompressorOxide::new());
self.decompress(input, output, output_position, end_of_input)
}
Err(_) => (TINFLStatus::Failed, 0, 0),
Expand Down

0 comments on commit 1144b3d

Please sign in to comment.