fix(decompress): Handle split RAR archives (#4994)

This commit is contained in:
Issac Lin
2022-06-24 22:15:54 +08:00
committed by GitHub
parent c4d1b9c22f
commit 1b5ee6f090
4 changed files with 22 additions and 1 deletions
+1
View File
@@ -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
+3
View File
@@ -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
}
+18 -1
View File
@@ -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
}
}
Binary file not shown.