Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,22 @@ function Save-File {
if ($PSVersionTable.PSVersion.Major -lt 6) {
$parameters.UseBasicParsing = $true
}
try {
Invoke-WebRequest @parameters
} catch {
Remove-Item -LiteralPath $OutputPath -Force -ErrorAction SilentlyContinue
Fail "${FailureMessage}: $($_.Exception.Message)"

# An HTTP transfer can fail transiently (a momentary connection reset, or
# the server-side listener still finishing setup) even though a retry a
# moment later succeeds; give it a couple of chances before giving up.
$maxAttempts = 3
for ($attempt = 1; $attempt -le $maxAttempts; $attempt++) {
try {
Invoke-WebRequest @parameters
return
} catch {
Remove-Item -LiteralPath $OutputPath -Force -ErrorAction SilentlyContinue
if ($attempt -eq $maxAttempts) {
Fail "${FailureMessage}: $($_.Exception.Message)"
}
Start-Sleep -Milliseconds (250 * $attempt)
}
}
}

Expand Down