Merged
Conversation
…ush-issue Fix EntryStream.Dispose() throwing NotSupportedException on non-seekable streams
182fc51 to
7732fbb
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR cherry-picks a fix for issue #1150 where EntryStream.Dispose() was throwing NotSupportedException when flushing Deflate/LZMA streams on non-seekable streams. The fix wraps the Flush() and FlushAsync() calls in try-catch blocks to gracefully handle unsupported stream operations.
Changes:
- Added exception handling to
EntryStream.Dispose()andDisposeAsync()to catch and ignoreNotSupportedExceptionfrom flush operations - Version bumped from 0.42.0 to 0.42.1
- Added tests for the dispose fix and additional unrelated test improvements
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/SharpCompress/Common/EntryStream.cs | Added try-catch blocks around Flush/FlushAsync calls in Dispose/DisposeAsync to prevent NotSupportedException from breaking disposal |
| tests/SharpCompress.Test/Zip/ZipReaderTests.cs | Added sync tests for non-seekable stream disposal (contains compilation errors) |
| tests/SharpCompress.Test/Zip/ZipReaderAsyncTests.cs | Added async tests for non-seekable stream disposal (contains compilation errors) |
| src/SharpCompress/SharpCompress.csproj | Bumped version to 0.42.1 for patch release |
| src/SharpCompress/Factories/ArjFactory.cs | Added try-catch to IsArchive to prevent exceptions on non-archive files |
| tests/SharpCompress.Test/ArchiveTests.cs | Added tests for ArchiveFactory.IsArchive behavior on non-archive files |
| tests/SharpCompress.Test/SharpCompress.Test.csproj | Added LEGACY_DOTNET constant for net48 and changed Mono.Posix to Linux-specific |
| .github/workflows/dotnetcore.yml | Added 'release' branch to CI triggers |
Comments suppressed due to low confidence (2)
tests/SharpCompress.Test/Zip/ZipReaderTests.cs:416
- The method
ZipReader.OpenReaderdoes not exist. Based on the ZipReader class (src/SharpCompress/Readers/Zip/ZipReader.cs), the correct method isZipReader.Open(stream). The test should use eitherZipReader.Open(stream)orReaderFactory.Open(stream).
var readerKeys = new List<string>();
tests/SharpCompress.Test/Zip/ZipReaderTests.cs:435
- This foreach loop immediately maps its iteration variable to another variable - consider mapping the sequence explicitly using '.Select(...)'.
var testFiles = new[] { "Zip.none.zip", "Zip.deflate.zip", "Zip.none.issue86.zip" };
foreach (var testFile in testFiles)
{
var path = Path.Combine(TEST_ARCHIVES_PATH, testFile);
var readerKeys = new List<string>();
using (var stream = File.OpenRead(path))
using (var reader = ZipReader.Open(stream))
{
while (reader.MoveToNextEntry())
{
readerKeys.Add(reader.Entry.Key!);
}
}
var archiveKeys = new List<string>();
using (var archive = Archives.Zip.ZipArchive.Open(path))
{
foreach (var entry in archive.Entries)
{
archiveKeys.Add(entry.Key!);
}
}
Assert.Equal(archiveKeys.Count, readerKeys.Count);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Jan 23, 2026
This was referenced Feb 2, 2026
This was referenced Feb 11, 2026
This was referenced Jan 26, 2026
This was referenced Feb 2, 2026
This was referenced Feb 11, 2026
This was referenced Feb 23, 2026
This was referenced Mar 2, 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.
Releasing #1150
Same as #1151