mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-04 05:25:00 +00:00
[PR #1114] [MERGED] Fix async decompression of .7z files by implementing Memory<byte> ReadAsync overload #1544
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/1114
Author: @Copilot
Created: 1/6/2026
Status: ✅ Merged
Merged: 1/7/2026
Merged by: @adamhathcock
Base:
master← Head:copilot/fix-7z-file-decompression-error📝 Commits (6)
2fde843Initial plan7116c0dAdd async support to BufferedSubStream for 7zip decompression0678318Fix async decompression by implementing Memory ReadAsync overloadb9258aduse more ValueTask methods but types are still created because of state machine suspension833dd7bfix tests and fmtfd968b3Update src/SharpCompress/IO/ReadOnlySubStream.cs📊 Changes
5 files changed (+354 additions, -5 deletions)
View changed files
📝
src/SharpCompress/Compressors/LZMA/LZ/LzOutWindow.cs(+25 -3)📝
src/SharpCompress/Compressors/LZMA/LzmaDecoder.cs(+2 -1)📝
src/SharpCompress/Compressors/LZMA/LzmaStream.cs(+114 -1)📝
src/SharpCompress/IO/BufferedSubStream.cs(+74 -0)➕
tests/SharpCompress.Test/SevenZip/SevenZipArchiveAsyncTests.cs(+139 -0)📄 Description
Async extraction of .7z files with LZMA/LZMA2 compression threw
DataErrorExceptionwhen usingCopyToAsync(), while synchronousCopyTo()worked correctly.Root Cause
In .NET 6+,
ReadExactlyAsynccallsReadAsync(Memory<byte>, CancellationToken).BufferedSubStreamonly implemented the legacybyte[]overload, causing the baseStreamclass to fall back to synchronous reads. This corrupted cache state when LZMA'sRangeCodermixed syncReadByte()calls with async operations.Changes
BufferedSubStream: AddedReadAsync(Memory<byte>, CancellationToken)andRefillCacheAsync()for true async I/OExample
The fix ensures async operations remain async throughout the decompression pipeline, preventing sync-over-async patterns.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.