mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-03 21:23:38 +00:00
[PR #1156] Fix silent iteration failure when input stream throws on Flush() #1600
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?
Original Pull Request: https://github.com/adamhathcock/sharpcompress/pull/1156
State: closed
Merged: Yes
Since 0.41.0, archive iteration stops after the first entry when the input stream throws
NotSupportedExceptioninFlush(). No exception is raised; iteration simply ends prematurely.Root cause:
ZlibBaseStream.Flush()unconditionally flushes the underlying stream regardless of read/write mode. WhenEntryStream.Dispose()callsFlush()on decompression streams (Deflate/LZMA), the flush propagates to the input stream, which:MultipartReaderStream, network streams, custom pipelines)NotSupportedExceptionis caughtChanges:
_streamMode == StreamMode.WriterExample of affected code:
With this fix, iteration completes successfully for all entries regardless of whether the input stream supports flushing.
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.