diff --git a/CHANGELOG.md b/CHANGELOG.md index d927861a57..9707edd90b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ ### Bug Fixes - **chore:** Update help documentation ([#5002](https://github.com/ScoopInstaller/Scoop/issues/5002)) +- **decompress:** Handle split RAR archives ([#4994](https://github.com/ScoopInstaller/Scoop/issues/4994)) - **shortcuts:** Fix network drive shortcut creation ([#4410](https://github.com/ScoopInstaller/Scoop/issues/4410)), ([#5006](https://github.com/ScoopInstaller/Scoop/issues/5006)) ### Code Refactoring diff --git a/lib/decompress.ps1 b/lib/decompress.ps1 index 3c4f3a9ffb..e7bcfea6cf 100644 --- a/lib/decompress.ps1 +++ b/lib/decompress.ps1 @@ -67,6 +67,9 @@ function Expand-7zipArchive { if (($Path -replace '.*\.([^\.]*)$', '$1') -eq '001') { # Remove splited 7-zip archive parts Get-ChildItem "$($Path -replace '\.[^\.]*$', '').???" | Remove-Item -Force + } elseif (($Path -replace '.*\.part(\d+)\.rar$', '$1')[-1] -eq '1') { + # Remove splitted RAR archive parts + Get-ChildItem "$($Path -replace '\.part(\d+)\.rar$', '').part*.rar" | Remove-Item -Force } else { Remove-Item $Path -Force } diff --git a/test/Scoop-Decompress.Tests.ps1 b/test/Scoop-Decompress.Tests.ps1 index 0bdc20f363..b568ef8e56 100644 --- a/test/Scoop-Decompress.Tests.ps1 +++ b/test/Scoop-Decompress.Tests.ps1 @@ -22,7 +22,7 @@ Describe 'Decompression function' -Tag 'Scoop', 'Decompress' { It 'Decompression test cases should exist' { $testcases = "$working_dir\TestCases.zip" $testcases | Should -Exist - compute_hash $testcases 'sha256' | Should -Be '16507166814dbd02be80c14b737eb6b0245c47439ca3ed308b5625d64babecc8' + compute_hash $testcases 'sha256' | Should -Be '791bfce192917a2ff225dcdd87d23ae5f720b20178d85e68e4b1b56139cf8e6a' if (!$isUnix) { Microsoft.PowerShell.Archive\Expand-Archive $testcases $working_dir } @@ -44,6 +44,9 @@ Describe 'Decompression function' -Tag 'Scoop', 'Decompress' { $test5_1 = "$working_dir\7ZipTest5.7z.001" $test5_2 = "$working_dir\7ZipTest5.7z.002" $test5_3 = "$working_dir\7ZipTest5.7z.003" + $test6_1 = "$working_dir\7ZipTest6.part01.rar" + $test6_2 = "$working_dir\7ZipTest6.part02.rar" + $test6_3 = "$working_dir\7ZipTest6.part03.rar" } It 'extract normal compressed file' -Skip:$isUnix { @@ -81,6 +84,13 @@ Describe 'Decompression function' -Tag 'Scoop', 'Decompress' { (Get-ChildItem $to).Count | Should -Be 1 } + It 'extract splited RAR archives (.part01.rar, .part02.rar, ...)' -Skip:$isUnix { + $to = test_extract 'Expand-7zipArchive' $test6_1 + $to | Should -Exist + "$to\dummy" | Should -Exist + (Get-ChildItem $to).Count | Should -Be 1 + } + It 'works with "-Removal" switch ($removal param)' -Skip:$isUnix { $test1 | Should -Exist test_extract 'Expand-7zipArchive' $test1 $true @@ -92,6 +102,13 @@ Describe 'Decompression function' -Tag 'Scoop', 'Decompress' { $test5_1 | Should -Not -Exist $test5_2 | Should -Not -Exist $test5_3 | Should -Not -Exist + $test6_1 | Should -Exist + $test6_2 | Should -Exist + $test6_3 | Should -Exist + test_extract 'Expand-7zipArchive' $test6_1 $true + $test6_1 | Should -Not -Exist + $test6_2 | Should -Not -Exist + $test6_3 | Should -Not -Exist } } diff --git a/test/fixtures/decompress/TestCases.zip b/test/fixtures/decompress/TestCases.zip index fd5115405a..12a891eee9 100644 Binary files a/test/fixtures/decompress/TestCases.zip and b/test/fixtures/decompress/TestCases.zip differ