[Windows] Reengineer the way of getting the installer for PostgreSQL (#7065)

This commit is contained in:
Alexey-Ayupov
2023-02-08 18:27:46 +03:00
committed by GitHub
parent 8361bb299b
commit 8282937409

View File

@@ -28,16 +28,22 @@ $TargetMinorVersions = ($MinorVersions | Sort-Object)[-1]
$ErrorActionOldValue = $ErrorActionPreference $ErrorActionOldValue = $ErrorActionPreference
$ErrorActionPreference = 'SilentlyContinue' $ErrorActionPreference = 'SilentlyContinue'
# Starting from number 9 and going down, check if the installer is available. If yes, break the loop. # Starting from number 9 and going down, check if the installer is available. If yes, break the loop.
foreach ($increment in 9..0) { # If an installer with $TargetMinorVersions is not to be found, the $TargetMinorVersions will be decreased by 1
$increment = 9
do {
$url = "https://get.enterprisedb.com/postgresql/postgresql-$toolsetVersion.$TargetMinorVersions-$increment-windows-x64.exe" $url = "https://get.enterprisedb.com/postgresql/postgresql-$toolsetVersion.$TargetMinorVersions-$increment-windows-x64.exe"
$checkaccess = [System.Net.WebRequest]::Create($url) $checkaccess = [System.Net.WebRequest]::Create($url)
$response = $null $response = $null
$response = $checkaccess.GetResponse() $response = $checkaccess.GetResponse()
if ($response) { if ($response) {
$InstallerUrl = $response.ResponseUri.OriginalString $InstallerUrl = $response.ResponseUri.OriginalString
break } elseif (!$response -and ($increment -eq 0)) {
} $increment = 9
$TargetMinorVersions--
} else {
$increment--
} }
} while (!$response)
# Return the previous value of ErrorAction and invoke Install-Binary function # Return the previous value of ErrorAction and invoke Install-Binary function
$ErrorActionPreference = $ErrorActionOldValue $ErrorActionPreference = $ErrorActionOldValue
$InstallerName = $InstallerUrl.Split('/')[-1] $InstallerName = $InstallerUrl.Split('/')[-1]