mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-14 21:23:38 +00:00
[PR #1156] [MERGED] Fix silent iteration failure when input stream throws on Flush() #1596
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/1156
Author: @Copilot
Created: 1/23/2026
Status: ✅ Merged
Merged: 1/24/2026
Merged by: @adamhathcock
Base:
master← Head:copilot/fix-sharpcompress-archive-iteration📝 Commits (4)
d0f4483Initial plan41e0c15Fix regression: archive iteration breaking when input stream throws in Flush()f2bb81dAdd async versions of archive iteration regression testsf1102dcUndoing https://github.com/adamhathcock/sharpcompress/pull/1151📊 Changes
6 files changed (+193 additions, -40 deletions)
View changed files
📝
src/SharpCompress/Common/EntryStream.cs(+4 -32)📝
src/SharpCompress/Compressors/Deflate/ZlibBaseStream.cs(+14 -2)📝
src/SharpCompress/packages.lock.json(+6 -6)➕
tests/SharpCompress.Test/Mocks/ThrowOnFlushStream.cs(+73 -0)📝
tests/SharpCompress.Test/Zip/ZipReaderAsyncTests.cs(+48 -0)📝
tests/SharpCompress.Test/Zip/ZipReaderTests.cs(+48 -0)📄 Description
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.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.