mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-03 21:23:38 +00:00
[PR #638] [MERGED] Rar2 fix with new unit tests that fail on previous build. #1135
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/638
Author: @Nanook
Created: 2/15/2022
Status: ✅ Merged
Merged: 2/16/2022
Merged by: @adamhathcock
Base:
master← Head:rar2MultiWithTest📝 Commits (1)
dab157bRar2 fix with new unit tests that fail on previous build.📊 Changes
10 files changed (+26 additions, -1 deletions)
View changed files
📝
src/SharpCompress/Common/Rar/RarEntry.cs(+1 -1)📝
tests/SharpCompress.Test/Rar/RarArchiveTests.cs(+25 -0)➕
tests/TestArchives/Archives/Rar2.multi.r00(+0 -0)➕
tests/TestArchives/Archives/Rar2.multi.r01(+0 -0)➕
tests/TestArchives/Archives/Rar2.multi.r02(+0 -0)➕
tests/TestArchives/Archives/Rar2.multi.r03(+0 -0)➕
tests/TestArchives/Archives/Rar2.multi.r04(+0 -0)➕
tests/TestArchives/Archives/Rar2.multi.r05(+0 -0)➕
tests/TestArchives/Archives/Rar2.multi.rar(+0 -0)➕
tests/TestArchives/Archives/Rar2.rar(+0 -0)📄 Description
I noticed files within WinRar2.8 archives were not decompressing properly. Some were fine, others were fine at the start then corrupt half way through the file. I was able to reproduce this behaviour by using WinRar2.8 to create SharpCompress test archives.
After debugging the streams to confirm the RAR compressed parts were being extracted correctly, I noticed it was the decoding that was failing. I stumbled upon
RarEntry.IsRarV3property and addedFileHeader.CompressionAlgorithm == 20 || FileHeader.CompressionAlgorithm == 26to the logic. This forces it to use the UnpackV1 code rather than UnpackV2017. This fixes it.This PR also includes the UnitTests and Archives. Hopefully it will be useful
I think it fixes this issue also: https://github.com/adamhathcock/sharpcompress/issues/619
Thanks.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.