fix(decompress): Check .zst first

And also trim `\` in `-DestinationPath`
This commit is contained in:
Hsiao-nan Cheung
2021-11-10 11:11:45 +08:00
parent af7a6f6d0e
commit e35ff313a5
2 changed files with 5 additions and 4 deletions

View File

@@ -143,8 +143,9 @@ function Expand-ZstdArchive {
) )
$ZstdPath = Get-HelperPath -Helper Zstd $ZstdPath = Get-HelperPath -Helper Zstd
$LogPath = "$(Split-Path $Path)\zstd.log" $LogPath = "$(Split-Path $Path)\zstd.log"
$DestinationPath = $DestinationPath.TrimEnd("\")
ensure $DestinationPath | Out-Null ensure $DestinationPath | Out-Null
$ArgList = @('-d', "`"$Path`"", '--output-dir-flat', "`"$DestinationPath`"") $ArgList = @('-d', "`"$Path`"", '--output-dir-flat', "`"$DestinationPath`"", "-v")
if ($Switches) { if ($Switches) {
$ArgList += (-split $Switches) $ArgList += (-split $Switches)
} }
@@ -164,7 +165,7 @@ function Expand-ZstdArchive {
} }
if ($IsTar) { if ($IsTar) {
# Check for tar # Check for tar
$TarFile = Get-ChildItem -Path $DestinationPath -Filter '*.tar' $TarFile = (strip_ext $Path)
Expand-7zipArchive -Path "$TarFile" -DestinationPath $DestinationPath -ExtractDir $ExtractDir -Removal Expand-7zipArchive -Path "$TarFile" -DestinationPath $DestinationPath -ExtractDir $ExtractDir -Removal
} }
if ($Removal) { if ($Removal) {

View File

@@ -596,10 +596,10 @@ function dl_urls($app, $version, $manifest, $bucket, $architecture, $dir, $use_c
} else { } else {
$extract_fn = 'Expand-MsiArchive' $extract_fn = 'Expand-MsiArchive'
} }
} elseif(Test-ZstdRequirement -File $fname) { # Zstd first
$extract_fn = 'Expand-ZstdArchive'
} elseif(Test-7zipRequirement -File $fname) { # 7zip } elseif(Test-7zipRequirement -File $fname) { # 7zip
$extract_fn = 'Expand-7zipArchive' $extract_fn = 'Expand-7zipArchive'
} elseif(Test-ZstdRequirement -File $fname) { # Zstd
$extract_fn = 'Expand-ZstdArchive'
} }
if($extract_fn) { if($extract_fn) {