Skip to content

Conversation

@jeckersb
Copy link
Collaborator

For things like GzDecoder, we don't want to read via the actual
decompression reader because we don't care about decompressing at this
point. Plus, the inner reader may have encountered an error partway
through, and trying to decode via decompression will error with
UnexpectedEof.

Instead, wrap a reader for each content type which knows how to get a
mutable reference to the underlying data stream. When we finish
decompressing, read directly from this "inner" stream to flush any
data.

Resolves: #1407
Signed-off-by: John Eckersberg [email protected]

@jeckersb
Copy link
Collaborator Author

This was quite the exercise in fighting the type system, but I think this is generally what we want...

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a Decompressable trait to handle flushing the underlying stream when a decompressor finishes, preventing UnexpectedEof errors. The implementation is clean, and tests for incomplete gzip and zstd data are included. A suggestion is provided to optimize TransparentDecompressor.

@jeckersb jeckersb force-pushed the decompressor_finish_on_inner branch from 147c387 to cc52892 Compare July 16, 2025 19:14
@jeckersb
Copy link
Collaborator Author

Trying something new... added a semi-casual commit just to keep things clear as feedback is addressed during the review process. We'll squash those out at the end.

Copy link
Collaborator

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! There's more code motion here but I think it really makes things a good bit cleaner to have all the gory details hidden inside that module.

}

#[cfg(test)]
mod tests {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These all look great!

@cgwalters
Copy link
Collaborator

Let's avoid merging main into PRs, can you just squash everything?

@cgwalters cgwalters marked this pull request as draft July 17, 2025 22:05
@jeckersb
Copy link
Collaborator Author

Trying something new... added a semi-casual commit just to keep things clear as feedback is addressed during the review process. We'll squash those out at the end.

^^^

Always intended on squashing it, which is why I just merged main in for now. More to the theme of making it easier to follow what's going on as we iterate here instead of force pushing repeatedly.

@cgwalters
Copy link
Collaborator

In general let's follow a SOP of keeping things draft if they're not ready to merge - and being "ready to merge" should include having a reasonably clean commit history where fixups are squashed.

This moves all of the code related to handling decompression out of
container/unencapsulate.rs and into a new module `generic_decompress`.
The only exposed API is via the existing (relocated) `Decompressor`
type.

Internal to `generic_decompress` this adds a new trait
`ReadWithGetInnerMut`, which allows access to the original, inner,
un-decompressed stream.  This is used when finishing the decompressor,
whether explicitly through calling its `finish()` method, or
implicitly by dropping it.

For things like GzDecoder, we don't want to read via the actual
decompression reader because we don't care about decompressing at this
point.  Plus, the inner reader may have encountered an error partway
through, and trying to decode via decompression will error with
UnexpectedEof.

Instead, wrap a reader for each content type which implements
`ReadWithGetInnerMut`.  When we finish decompressing, use the trait
method `get_inner_mut()` to read directly from inner stream to flush
any data.

Resolves: bootc-dev#1407
Signed-off-by: John Eckersberg <[email protected]>
@jeckersb jeckersb force-pushed the decompressor_finish_on_inner branch from c3c5f5e to 75d5e71 Compare July 17, 2025 22:21
@jeckersb jeckersb marked this pull request as ready for review July 17, 2025 22:22
@cgwalters cgwalters merged commit 778ec6a into bootc-dev:main Jul 17, 2025
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

panic on unexpected EOF during pull

2 participants