Skip to content

Commit 606bed9

Browse files
committed
FIX: Extract zip win
Related to #819 Changes include: - Fixing ExtractToDirectory call by removing third attribute. This function accepts a third argument but it should be of type 'System.Text.Encoding' not 'System.Boolean' - Reordering extract utils to first attemps ExtractToDirectory and then Expand-Archive. For some reason the download CPython release was not correctly handled by Expand-Archive. This could be happening if the zip file was compressed using an unsupported compression method (e.g. through `zip` with Unix/linux).
1 parent 871daa9 commit 606bed9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

dist/setup/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9861,7 +9861,7 @@ function extractZipWin(file, dest) {
98619861
const pwshCommand = [
98629862
`$ErrorActionPreference = 'Stop' ;`,
98639863
`try { Add-Type -AssemblyName System.IO.Compression.ZipFile } catch { } ;`,
9864-
`try { [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}', $true) }`,
9864+
`try { [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}') }`,
98659865
`catch { if (($_.Exception.GetType().FullName -eq 'System.Management.Automation.MethodException') -or ($_.Exception.GetType().FullName -eq 'System.Management.Automation.RuntimeException') ){ Expand-Archive -LiteralPath '${escapedFile}' -DestinationPath '${escapedDest}' -Force } else { throw $_ } } ;`
98669866
].join(' ');
98679867
const args = [
@@ -9877,11 +9877,12 @@ function extractZipWin(file, dest) {
98779877
yield exec_1.exec(`"${pwshPath}"`, args);
98789878
}
98799879
else {
9880+
//attempt to use pwsh with ExtractToDirectory, if this fails attempt Expand-Archive
98809881
const powershellCommand = [
98819882
`$ErrorActionPreference = 'Stop' ;`,
98829883
`try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ;`,
9883-
`if ((Get-Command -Name Expand-Archive -Module Microsoft.PowerShell.Archive -ErrorAction Ignore)) { Expand-Archive -LiteralPath '${escapedFile}' -DestinationPath '${escapedDest}' -Force }`,
9884-
`else {[System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}', $true) }`
9884+
`try { [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}') }`,
9885+
`catch { if (($_.Exception.GetType().FullName -eq 'System.Management.Automation.MethodException') -or ($_.Exception.GetType().FullName -eq 'System.Management.Automation.RuntimeException') ){ Expand-Archive -LiteralPath '${escapedFile}' -DestinationPath '${escapedDest}' -Force } else { throw $_ } } ;`
98859886
].join(' ');
98869887
const args = [
98879888
'-NoLogo',

0 commit comments

Comments
 (0)