mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-04 05:25:00 +00:00
[PR #1114] Fix async decompression of .7z files by implementing Memory<byte> ReadAsync overload #1546
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/1114
State: closed
Merged: Yes
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.