-
Notifications
You must be signed in to change notification settings - Fork 512
RAR5 (and maybe others) async methods are different #1203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
103ae60
e786c00
218af5a
cd5da3d
ab1dd45
6f50545
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,162 @@ | ||||||
| using System; | ||||||
| using System.Threading; | ||||||
| using System.Threading.Tasks; | ||||||
| using SharpCompress.Compressors.Rar.UnpackV1.Decode; | ||||||
|
|
||||||
| namespace SharpCompress.Compressors.Rar.UnpackV1; | ||||||
|
|
||||||
| internal partial class Unpack | ||||||
| { | ||||||
| private async Task unpack15Async(bool solid, CancellationToken cancellationToken = default) | ||||||
| { | ||||||
| if (suspended) | ||||||
| { | ||||||
| unpPtr = wrPtr; | ||||||
| } | ||||||
| else | ||||||
| { | ||||||
| UnpInitData(solid); | ||||||
| oldUnpInitData(solid); | ||||||
| await unpReadBufAsync(cancellationToken).ConfigureAwait(false); | ||||||
| if (!solid) | ||||||
| { | ||||||
| initHuff(); | ||||||
| unpPtr = 0; | ||||||
| } | ||||||
| else | ||||||
| { | ||||||
| unpPtr = wrPtr; | ||||||
| } | ||||||
| --destUnpSize; | ||||||
| } | ||||||
| if (destUnpSize >= 0) | ||||||
| { | ||||||
| getFlagsBuf(); | ||||||
| FlagsCnt = 8; | ||||||
| } | ||||||
|
|
||||||
| while (destUnpSize >= 0) | ||||||
| { | ||||||
| unpPtr &= PackDef.MAXWINMASK; | ||||||
|
|
||||||
| if ( | ||||||
| inAddr > readTop - 30 | ||||||
| && !await unpReadBufAsync(cancellationToken).ConfigureAwait(false) | ||||||
| ) | ||||||
| { | ||||||
| break; | ||||||
| } | ||||||
| if (((wrPtr - unpPtr) & PackDef.MAXWINMASK) < 270 && wrPtr != unpPtr) | ||||||
| { | ||||||
| oldUnpWriteBuf(); | ||||||
| if (suspended) | ||||||
| { | ||||||
| return; | ||||||
| } | ||||||
| } | ||||||
| if (StMode != 0) | ||||||
| { | ||||||
| huffDecode(); | ||||||
| continue; | ||||||
| } | ||||||
|
|
||||||
| if (--FlagsCnt < 0) | ||||||
| { | ||||||
| getFlagsBuf(); | ||||||
| FlagsCnt = 7; | ||||||
| } | ||||||
|
|
||||||
| if ((FlagBuf & 0x80) != 0) | ||||||
| { | ||||||
| FlagBuf <<= 1; | ||||||
| if (Nlzb > Nhfb) | ||||||
| { | ||||||
| longLZ(); | ||||||
| } | ||||||
| else | ||||||
| { | ||||||
| huffDecode(); | ||||||
| } | ||||||
| } | ||||||
| else | ||||||
| { | ||||||
| FlagBuf <<= 1; | ||||||
| if (--FlagsCnt < 0) | ||||||
| { | ||||||
| getFlagsBuf(); | ||||||
| FlagsCnt = 7; | ||||||
| } | ||||||
| if ((FlagBuf & 0x80) != 0) | ||||||
| { | ||||||
| FlagBuf <<= 1; | ||||||
| if (Nlzb > Nhfb) | ||||||
| { | ||||||
| huffDecode(); | ||||||
| } | ||||||
| else | ||||||
| { | ||||||
| longLZ(); | ||||||
| } | ||||||
| } | ||||||
| else | ||||||
| { | ||||||
| FlagBuf <<= 1; | ||||||
| shortLZ(); | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| oldUnpWriteBuf(); | ||||||
|
||||||
| oldUnpWriteBuf(); | |
| await oldUnpWriteBufAsync(cancellationToken).ConfigureAwait(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unpack15Asyncflushes usingoldUnpWriteBuf()(syncStream.Write) instead of the available async variant. This blocks the async extraction path and ignores the providedCancellationToken. Useawait oldUnpWriteBufAsync(cancellationToken).ConfigureAwait(false)here.