Fix flat GZip via ReaderFactory: SeekableSharpCompressStream.StopRecording() must seek back to anchor - #1392
Closed
adamhathcock with Copilot wants to merge 2 commits into
Closed
Fix flat GZip via ReaderFactory: SeekableSharpCompressStream.StopRecording() must seek back to anchor#1392adamhathcock with Copilot wants to merge 2 commits into
adamhathcock with Copilot wants to merge 2 commits into
Conversation
… position When SeekableSharpCompressStream.StopRecording() was called (e.g. after the tar probe in GZipFactory.TryOpenReader), it cleared _recordedPosition without seeking back to it. This left the underlying FileStream at the advanced position reached during the probe, so the subsequent GZipReader would start reading from the wrong offset, producing Key=null and 0 extracted bytes. Fix: seek back to _recordedPosition before clearing it, matching the behavior of the non-seekable SharpCompressStream.StopRecording() which rewinds _logicalPosition. Also enhance the existing GZip_ReaderFactory_FlatGZip test to actually verify the extracted content (not just MoveToNextEntry returns true), and add an async variant. Closes #1391
Copilot
AI
changed the title
[WIP] Fix flat GZip via ReaderFactory stream rewind issue
Fix flat GZip via ReaderFactory: SeekableSharpCompressStream.StopRecording() must seek back to anchor
Jul 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ReaderFactory.OpenReaderon a flat.gzfile (non-tar) producedKey=nulland extracted 0 bytes becauseSeekableSharpCompressStream.StopRecording()cleared_recordedPositionwithout seeking back to it.After
GZipFactory.TryOpenReaderruns the tar probe (decompressing the entire GZip stream to check for a tar header), the underlyingFileStreamis left at an advanced position.StopRecording()must rewind before clearing the anchor — the non-seekableSharpCompressStreamalready does this by resetting_logicalPosition, but the seekable override was missing the seek.Changes
SeekableSharpCompressStream.StopRecording()— seek to_recordedPositionbefore clearing it, matching the non-seekable implementation's behavior of rewinding to the recording anchor on stop.GZipReaderTests.GZip_ReaderFactory_FlatGZip— extended to verify the extracted bytes, not just thatMoveToNextEntry()returnstrue(the prior assertion missed the actual regression).GZipReaderAsyncTests.GZip_ReaderFactory_FlatGZip_Async— async equivalent of the above.