mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-14 13:35:38 +00:00
[PR #1113] Fix a usage of ReadOnly that use dispose in 7Zip #1543
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/1113
State: closed
Merged: Yes
Maybe addresses https://github.com/adamhathcock/sharpcompress/issues/1105
This pull request improves stream disposal behavior and consistency across several stream types in the SharpCompress library, refactors the implementation of stream skipping utilities, and adds comprehensive tests to verify correct disposal semantics. The main changes are grouped below.
Stream disposal and leaveOpen support improvements:
ReadOnlySubStreamconstructors to accept aleaveOpenparameter, ensuring the inner stream is disposed correctly based on this flag.SevenZipFilePart.GetCompressedStream()to explicitly setleaveOpen: falsewhen creating aReadOnlySubStream, ensuring proper disposal of the underlying stream.LZipStreamto store a reference to the original stream and updated itsDisposemethod to dispose the original stream only in compression mode, improving disposal correctness. [1] [2]Stream skipping utilities refactor:
Stream.Skip,Stream.SkipAsync, and related methods inUtility.csto useReadOnlySubStreamandStream.Null, reducing buffer management complexity and improving maintainability.Testing and verification:
DisposalTestssuite to verify the disposal behavior of various stream implementations, including checks for correct handling of theleaveOpenparameter and always/never disposal patterns.Minor cleanup:
IsRecordingproperty fromSharpCompressStream, streamlining the codebase.