From 32e864271d76a211d7390e2ab0d2134bd4a991df Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Sun, 21 Dec 2025 00:23:24 +0900 Subject: [PATCH] Add curl fallback for file downloads in postInstall.ps1 Updated the Download-File function to use curl as a fallback if PowerShell download fails. Also added curl.exe and curl-ca-bundle.crt to the installer in setup.iss to ensure curl is available during installation. --- postInstall.ps1 | 25 +++++++++++++++++++++---- setup.iss | 2 ++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/postInstall.ps1 b/postInstall.ps1 index 0aa5aed..55e70ef 100644 --- a/postInstall.ps1 +++ b/postInstall.ps1 @@ -1,6 +1,6 @@ # WelsonJS post-install script # Namhyeon Go , and Catswords OSS contributors. -# Updated on: 2025-12-20 +# Updated on: 2025-12-21 # https://github.com/gnh1201/welsonjs # ================================ @@ -298,11 +298,9 @@ function Download-File { $protocol = [Net.SecurityProtocolType]::Tls12 -bor ` [Net.SecurityProtocolType]::Tls11 -bor ` [Net.SecurityProtocolType]::Tls - try { $protocol = $protocol -bor [Enum]::Parse([Net.SecurityProtocolType], 'Tls13') } catch {} - [Net.ServicePointManager]::SecurityProtocol = $protocol } catch { @@ -334,7 +332,26 @@ function Download-File { } if (-not $success) { - throw "Failed to download $Url after $maxRetries attempts." + Write-Host "[WARN] PowerShell download failed. Falling back to curl." + + $curlPath = Join-Path $ScriptRoot "bin\x86\curl.exe" + if (-not (Test-Path $curlPath)) { + throw "curl not found at $curlPath" + } + + $curlArgs = @( + "-L" + "--fail" + "--retry", "3" + "--retry-delay", "5" + "-o", $DestinationPath + $Url + ) + + $proc = Start-Process -FilePath $curlPath -ArgumentList $curlArgs -NoNewWindow -Wait -PassThru + if ($proc.ExitCode -ne 0 -or -not (Test-Path $DestinationPath)) { + throw "curl download failed with exit code $($proc.ExitCode)." + } } } diff --git a/setup.iss b/setup.iss index 258ea6c..c466dc2 100644 --- a/setup.iss +++ b/setup.iss @@ -76,6 +76,8 @@ Source: "app\*"; DestDir: "{app}/app"; Flags: ignoreversion recursesubdirs; Source: "lib\*"; DestDir: "{app}/lib"; Flags: ignoreversion recursesubdirs; ; Source: "bin\*"; Excludes: "installer\*"; DestDir: "{app}/bin"; Flags: ignoreversion recursesubdirs; Source: "bin\x86\7zr.exe"; DestDir: "{app}/bin/x86"; Flags: ignoreversion recursesubdirs; +Source: "bin\x86\curl.exe"; DestDir: "{app}/bin/x86"; Flags: ignoreversion recursesubdirs; +Source: "bin\x86\curl-ca-bundle.crt"; DestDir: "{app}/bin/x86"; Flags: ignoreversion recursesubdirs; Source: "bin\x86\WelsonJS.Launcher.exe"; DestDir: "{app}/bin/x86"; Flags: ignoreversion recursesubdirs; Source: "bin\x86\WelsonJS.Launcher.exe.config"; DestDir: "{app}/bin/x86"; Flags: ignoreversion recursesubdirs; Source: "data\*"; Excludes: "*-apikey.txt"; DestDir: "{app}/data"; Flags: ignoreversion recursesubdirs;