Fix TarFactory.cs formatting to unblock CI - #1404
Merged
Merged
Conversation
Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix failing GitHub Actions job for NuGet Release
Fix TarFactory.cs formatting to unblock CI
Aug 4, 2026
adamhathcock
approved these changes
Aug 4, 2026
adamhathcock
marked this pull request as ready for review
August 4, 2026 07:23
adamhathcock
enabled auto-merge
August 4, 2026 07:23
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes TarFactory.OpenReader to avoid allocating a large rewind ring buffer when the real underlying stream is already seekable, while also ensuring the stream position is rewound before ending the recording scope so TarReader always starts from the correct position. This aligns OpenReader with the already-correct rewind behavior in OpenAsyncReader and unblocks CI formatting checks.
Changes:
- Added
IsGenuinelySeekable(Stream)to unwrap nestedSharpCompressStreamlayers before checking true underlyingCanSeek. - Added
CreateNestedRecordingStream(Stream)to useSeekableSharpCompressStreamfor genuinely seekable streams (avoids ring-buffer allocation), otherwise fall back to a ring-bufferedSharpCompressStream. - Updated
OpenReaderto use the helper and toRewind()beforeStopRecording()when a wrapper match succeeds.
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.
The
NuGet Release / build-and-publishCI job was failing becauseCreateNestedRecordingStreamand its closing brace were not indented within the class body, causingdotnet csharpier checkto exit with code 1.Changes
TarFactory.cs: Added two new private helper methods (from PR Tar: Fix memory leak regression #1403) with correct CSharpier-compliant indentation:IsGenuinelySeekable(Stream)— unwraps nestedSharpCompressStreamlayers to check whether the underlying stream genuinely supportsSeekCreateNestedRecordingStream(Stream)— returns aSeekableSharpCompressStreamfor seekable streams (no ring buffer allocation) or a ring-bufferedSharpCompressStreamfor non-seekable streamsOpenReader: switched fromnew SharpCompressStream(stream)toCreateNestedRecordingStream(stream), and addedsharpCompressStream.Rewind()beforeStopRecording()so the reader position is reset before handing the stream toTarReader