File tree Expand file tree Collapse file tree 2 files changed +48
-4
lines changed
.github/workflows/scripts/windows Expand file tree Collapse file tree 2 files changed +48
-4
lines changed Original file line number Diff line number Diff line change @@ -14,8 +14,30 @@ $VSB_SHA256='C792BDB0FD46155DE19955269CAC85D52C4C63C23DB2CF43D96B9390146F9390'
1414Set-Variable ErrorActionPreference Stop
1515Set-Variable ProgressPreference SilentlyContinue
1616Write-Host - NoNewLine (' Downloading {0} ... ' -f ${VSB} )
17- Invoke-WebRequest - Uri $VSB - OutFile $env: TEMP \vs_buildtools.exe
18- Write-Host ' SUCCESS'
17+ $MaxRetries = 10
18+ $BaseDelay = 1
19+ $Attempt = 0
20+ $Success = $false
21+
22+ while (-not $Success -and $Attempt -lt $MaxRetries ) {
23+ $Attempt ++
24+ try {
25+ Invoke-WebRequest - Uri $VSB - OutFile $env: TEMP \vs_buildtools.exe
26+ $Success = $true
27+ Write-Host ' SUCCESS'
28+ }
29+ catch {
30+ if ($Attempt -eq $MaxRetries ) {
31+ Write-Host " FAILED after $MaxRetries attempts: $ ( $_.Exception.Message ) "
32+ exit 1
33+ }
34+
35+ # Calculate exponential backoff delay (2^attempt * base delay)
36+ $Delay = $BaseDelay * [Math ]::Pow(2 , $Attempt - 1 )
37+ Write-Host " Attempt $Attempt failed, retrying in $Delay seconds..."
38+ Start-Sleep - Seconds $Delay
39+ }
40+ }
1941Write-Host - NoNewLine (' Verifying SHA256 ({0}) ... ' -f $VSB_SHA256 )
2042$Hash = Get-FileHash $env: TEMP \vs_buildtools.exe - Algorithm sha256
2143if ($Hash.Hash -eq $VSB_SHA256 ) {
Original file line number Diff line number Diff line change @@ -17,8 +17,30 @@ function Install-Swift {
1717 Set-Variable ErrorActionPreference Stop
1818 Set-Variable ProgressPreference SilentlyContinue
1919 Write-Host - NoNewLine (' Downloading {0} ... ' -f $url )
20- Invoke-WebRequest - Uri $url - OutFile installer.exe
21- Write-Host ' SUCCESS'
20+ $MaxRetries = 10
21+ $BaseDelay = 1
22+ $Attempt = 0
23+ $Success = $false
24+
25+ while (-not $Success -and $Attempt -lt $MaxRetries ) {
26+ $Attempt ++
27+ try {
28+ Invoke-WebRequest - Uri $url - OutFile installer.exe
29+ $Success = $true
30+ Write-Host ' SUCCESS'
31+ }
32+ catch {
33+ if ($Attempt -eq $MaxRetries ) {
34+ Write-Host " FAILED after $MaxRetries attempts: $ ( $_.Exception.Message ) "
35+ exit 1
36+ }
37+
38+ # Calculate exponential backoff delay (2^attempt * base delay)
39+ $Delay = $BaseDelay * [Math ]::Pow(2 , $Attempt - 1 )
40+ Write-Host " Attempt $Attempt failed, retrying in $Delay seconds..."
41+ Start-Sleep - Seconds $Delay
42+ }
43+ }
2244 Write-Host - NoNewLine (' Verifying SHA256 ({0}) ... ' -f $Sha256 )
2345 $Hash = Get-FileHash installer.exe - Algorithm sha256
2446 if ($Hash.Hash -eq $Sha256 -or $Sha256 -eq " " ) {
You can’t perform that action at this time.
0 commit comments