mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-11 13:35:00 +00:00
[PR #1151] [MERGED] Fix EntryStream.Dispose() throwing NotSupportedException on non-seekable streams #1586
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/adamhathcock/sharpcompress/pull/1151
Author: @Copilot
Created: 1/22/2026
Status: ✅ Merged
Merged: 1/22/2026
Merged by: @adamhathcock
Base:
master← Head:copilot/fix-entrystream-flush-issue📝 Commits (6)
e6fb704Initial planf77a2aaFix EntryStream.Dispose() to not throw NotSupportedException on non-seekable streams8b74243Update test comments to include version context7cbdc5bFormat code with CSharpier9628f2dAdd async tests for EntryStream.Dispose on non-seekable streams1522e64fix async tests📊 Changes
4 files changed (+136 additions, -5 deletions)
View changed files
📝
src/SharpCompress/Common/EntryStream.cs(+32 -4)📝
tests/SharpCompress.Test/SharpCompress.Test.csproj(+4 -1)📝
tests/SharpCompress.Test/Zip/ZipReaderAsyncTests.cs(+54 -0)📝
tests/SharpCompress.Test/Zip/ZipReaderTests.cs(+46 -0)📄 Description
Fix EntryStream.Dispose() NotSupportedException on non-seekable streams
Problem
Since version 0.41.0,
EntryStream.Dispose()callsFlush()on DeflateStream and LzmaStream to handle over-read issues. However, this causesNotSupportedExceptionin legitimate streaming scenarios with non-seekable streams (e.g., ASP.NET Core HttpRequest.Body).Solution
Wrapped the
Flush()andFlushAsync()calls in try-catch blocks that safely ignoreNotSupportedException. This maintains the over-read correction behavior for streams that support it, while gracefully degrading for non-seekable streams.Plan
Changes Made
EntryStream.Dispose()to wrapFlush()calls in try-catch blocksEntryStream.DisposeAsync()to wrapFlushAsync()calls in try-catch blocksNotSupportedExceptionfrom Flush operationsEntryStream_Dispose_DoesNotThrow_OnNonSeekableStream_DeflateandEntryStream_Dispose_DoesNotThrow_OnNonSeekableStream_LZMAEntryStream_Dispose_DoesNotThrow_OnNonSeekableStream_Deflate_AsyncandEntryStream_Dispose_DoesNotThrow_OnNonSeekableStream_LZMA_AsyncTest Results
Security Summary
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.