Skip to content

Commit faf7a9d

Browse files
committed
Use curl with --retry
1 parent 79b5dd5 commit faf7a9d

File tree

3 files changed

+33
-81
lines changed

3 files changed

+33
-81
lines changed

.github/workflows/scripts/windows/install-vsb.ps1

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,28 @@
1010
##
1111
##===----------------------------------------------------------------------===##
1212

13-
Import-Module $PSScriptRoot\web-request-utils.psm1
14-
1513
$VSB='https://download.visualstudio.microsoft.com/download/pr/5536698c-711c-4834-876f-2817d31a2ef2/c792bdb0fd46155de19955269cac85d52c4c63c23db2cf43d96b9390146f9390/vs_BuildTools.exe'
1614
$VSB_SHA256='C792BDB0FD46155DE19955269CAC85D52C4C63C23DB2CF43D96B9390146F9390'
1715
Set-Variable ErrorActionPreference Stop
1816
Set-Variable ProgressPreference SilentlyContinue
1917
Write-Host -NoNewLine ('Downloading {0} ... ' -f ${VSB})
2018
try {
21-
Invoke-WebRequestWithRetry -Uri $VSB -OutFile $env:TEMP\vs_buildtools.exe
19+
# Use curl with retry logic (10 retries with built-in exponential backoff)
20+
$exitCode = (Start-Process -FilePath "curl" -ArgumentList @(
21+
"--retry", "10",
22+
"--retry-max-time", "300",
23+
"--location",
24+
"--output", "$env:TEMP\vs_buildtools.exe",
25+
$VSB
26+
) -Wait -PassThru -NoNewWindow).ExitCode
27+
28+
if ($exitCode -ne 0) {
29+
throw "curl failed with exit code $exitCode"
30+
}
31+
Write-Host 'SUCCESS'
2232
}
2333
catch {
34+
Write-Host "FAILED: $($_.Exception.Message)"
2435
exit 1
2536
}
2637
Write-Host -NoNewLine ('Verifying SHA256 ({0}) ... ' -f $VSB_SHA256)

.github/workflows/scripts/windows/swift/install-swift.ps1

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
##
1111
##===----------------------------------------------------------------------===##
1212

13-
Import-Module $PSScriptRoot\..\web-request-utils.psm1
14-
1513
function Install-Swift {
1614
param (
1715
[string]$Url,
@@ -21,9 +19,27 @@ function Install-Swift {
2119
Set-Variable ProgressPreference SilentlyContinue
2220
Write-Host -NoNewLine ('Downloading {0} ... ' -f $url)
2321
try {
24-
Invoke-WebRequestWithRetry -Uri $url -OutFile installer.exe
22+
# Use curl with retry logic (10 retries with exponential backoff starting at 1 second)
23+
# --retry-all-errors ensures we retry on transfer failures (e.g., exit code 18)
24+
# -C - enables resume for partial downloads
25+
$exitCode = (Start-Process -FilePath "curl" -ArgumentList @(
26+
"--retry", "10",
27+
"--retry-delay", "1",
28+
"--retry-all-errors",
29+
"--retry-max-time", "300",
30+
"--location",
31+
"-C", "-",
32+
"--output", "installer.exe",
33+
$url
34+
) -Wait -PassThru -NoNewWindow).ExitCode
35+
36+
if ($exitCode -ne 0) {
37+
throw "curl failed with exit code $exitCode"
38+
}
39+
Write-Host 'SUCCESS'
2540
}
2641
catch {
42+
Write-Host "FAILED: $($_.Exception.Message)"
2743
exit 1
2844
}
2945
Write-Host -NoNewLine ('Verifying SHA256 ({0}) ... ' -f $Sha256)

.github/workflows/scripts/windows/web-request-utils.psm1

Lines changed: 0 additions & 75 deletions
This file was deleted.

0 commit comments

Comments
 (0)