mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-03 21:23:38 +00:00
[PR #417] [MERGED] Allow Flush on EntryStream #1017
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/417
Author: @KyotoFox
Created: 10/4/2018
Status: ✅ Merged
Merged: 10/4/2018
Merged by: @adamhathcock
Base:
master← Head:fix-entrystream-flush📝 Commits (3)
efae832Don't throw an exception when flushing an EntryStream6dd5da4Added test that calls EntryStream.Flush()53ad00cUse soft tabs📊 Changes
4 files changed (+84 additions, -3 deletions)
View changed files
📝
src/SharpCompress/Common/EntryStream.cs(+1 -3)➕
tests/SharpCompress.Test/Mocks/FlushOnDisposeStream.cs(+57 -0)📝
tests/SharpCompress.Test/Tar/TarReaderTests.cs(+26 -0)➕
tests/TestArchives/Archives/Tar.ContainsTarGz.tar(+0 -0)📄 Description
I have a
tar-file that contains anothertar.gz-file that I want do extract using SharpCompress.When I am iterating through the outer
tar-file, and find thetar.gz-file I want to extract, I use a CryptoStream that calculates the SHA256-sum of thetar.gz-entry while I extract it (using the IReader extension WriteAllToDirectory)This seems to work without issues, but somtimes (due to CryptoStreams internal implementation), the
tar.gzEntryStream will throw aNotSupportedExceptionwhen the CryptoStream is being Disposed, because it will sometimes callFlush()on the EntryStream (see here).From what I can see there is no reason to not allow flushing the EntryStream, as there is nothing to flush. Microsoft also mentions in the Stream.Flush-documentation that read-only streams should implement Flush with an empty method.
This pull request fixes that, and also adds a test that "provokes" this issue (not sure if that is needed or wanted)
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.