File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6767
6868 $setupExe = "$vol\setup.exe"
6969 $setupFileName = "setup-$platform.exe"
70- Invoke-WebRequest "https://cygwin.com/$setupFileName" -OutFile $setupExe
70+
71+ $maxRetries = 5
72+ $retryCount = 0
73+ $success = $false
74+ $delay = 2
75+
76+ while (-not $success -and $retryCount -lt $maxRetries) {
77+ try {
78+ Invoke-WebRequest -Uri "https://cygwin.com/$setupFileName" -OutFile $setupExe
79+ $success = $true
80+ } catch {
81+ Write-Output "Attempt $($retryCount + 1) failed. Retrying..."
82+ Start-Sleep -Seconds $delay
83+ $retryCount++
84+ $delay += $delay
85+ }
86+ }
87+
88+ if (-not $success) {
89+ throw "Failed to download $setupFileName after $maxRetries attempts."
90+ }
91+
7192 if ((Get-Item -LiteralPath $setupExe).Length -eq 0) {
7293 throw "The downloaded setup has a zero length!"
7394 }
You can’t perform that action at this time.
0 commit comments