Skip to content

Commit eb7b522

Browse files
committed
Add retry logic for downloading files
1 parent 565d31b commit eb7b522

27 files changed

+163
-39
lines changed

extension/BuildPhpExtension/BuildPhpExtension.psd1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@
8383
'Get-BuildDirectory',
8484
'Get-Extension',
8585
'Get-ExtensionConfig',
86-
'Get-ExtensionSource',
86+
'Get-ExtensionSource'
87+
'Get-File',
8788
'Get-LibrariesFromConfig',
8889
'Get-OlderVsVersion',
8990
'Get-PeclLibraryZip',

extension/BuildPhpExtension/private/Add-Boost.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Function Add-Boost {
1010
}
1111
process {
1212
$url = "https://archives.boost.io/release/1.72.0/source/boost_1_72_0.zip"
13-
Invoke-WebRequest $url -OutFile "boost.zip"
13+
Get-File -Url -OutFile "boost.zip"
1414
Expand-Archive -Path "boost.zip" -DestinationPath "../deps"
1515
}
1616
end {

extension/BuildPhpExtension/private/Add-Extension.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Function Add-Extension {
2222
}
2323
process {
2424
Set-GAGroup start
25-
Invoke-WebRequest -Uri "https://pecl.php.net/get/$Extension" -OutFile "$Extension.tgz"
25+
Get-File -Url "https://pecl.php.net/get/$Extension" -OutFile "$Extension.tgz"
2626
$currentDirectory = (Get-Location).Path
2727
& tar -xzf "$Extension.tgz" -C $currentDirectory
2828
Set-Location "$Extension-*"

extension/BuildPhpExtension/private/Add-ExtensionDependencies.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Function Add-ExtensionDependencies {
3232
}
3333
Default {
3434
$url = "https://downloads.php.net/~windows/pecl/deps/$_"
35-
Invoke-WebRequest -Uri $url -OutFile $_ -UseBasicParsing
35+
Get-File -Url $url -OutFile $_
3636
Expand-Archive -Path $_ -DestinationPath "..\deps" -Force
3737
if(Test-Path "..\deps\LICENSE") {
3838
Rename-Item -Path "..\deps\LICENSE" -NewName "LICENSE.$library"

extension/BuildPhpExtension/private/Add-OciDB.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Function Add-OciDB {
1111
process {
1212
$dbUrl = 'https://download.oracle.com/otn-pub/otn_software/db-express/OracleXE213_Win64.zip'
1313
$dbZipFile = 'OracleXE213_Win64.zip'
14-
Invoke-WebRequest $dbUrl -OutFile $dbZipFile -UseBasicParsing -Verbose
14+
Get-File -Url $dbUrl -OutFile $dbZipFile
1515
New-Item -ItemType Directory -Path C:\tools\oracle-setup -Force | Out-Null
1616
New-Item -ItemType Directory -Path C:\tools\oracle -Force | Out-Null
1717
Expand-Archive -Path $dbZipFile -DestinationPath C:\tools\oracle-setup -Force

extension/BuildPhpExtension/private/Add-OciSdk.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Function Add-OciSdk {
1616
$suffix = if ($Config.arch -eq "x64") {"windows"} else {"nt"}
1717
@('sdk', 'basic') | ForEach-Object {
1818
$url = "https://download.oracle.com/otn_software/nt/instantclient/instantclient-$_-$suffix.zip"
19-
Invoke-WebRequest $url -OutFile "instantclient-$_.zip"
19+
Get-File -Url -OutFile "instantclient-$_.zip"
2020
Expand-Archive -Path "instantclient-$_.zip" -DestinationPath "../deps" -Force
2121
}
2222
Copy-Item ../deps/instantclient_*/sdk/* -Destination "../deps" -Recurse -Force

extension/BuildPhpExtension/private/Add-OdbcCli.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Function Add-OdbcCli {
1515
process {
1616
$prefix = if ($Config.arch -eq "x64") {"ntx64"} else {"nt32"}
1717
$url = "https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/${prefix}_odbc_cli.zip"
18-
Invoke-WebRequest $url -OutFile "odbc_cli.zip"
18+
Get-File -Url $url -OutFile "odbc_cli.zip"
1919
Expand-Archive -Path "odbc_cli.zip" -DestinationPath "../deps"
2020
Copy-Item ../deps/clidriver/* -Destination "../deps" -Recurse -Force
2121
}

extension/BuildPhpExtension/private/Add-Package.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function Add-Package {
5050
}
5151

5252
if(Test-Path ..\deps\bin) {
53-
$dllMap = Invoke-WebRequest -Uri "https://downloads.php.net/~windows/pecl/deps/dllmapping.json"
53+
$dllMap = Get-File -Url "https://downloads.php.net/~windows/pecl/deps/dllmapping.json"
5454
Get-ChildItem -Path ..\deps\bin -Recurse -Include "*.dll" | ForEach-Object {
5555
if($dllMap.content.Contains($_.Name)) {
5656
if(-not(Test-Path "php-bin\$($_.Name)")) {

extension/BuildPhpExtension/private/Add-PhpDependencies.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ Function Add-PhpDependencies {
1818
}
1919
$phpBaseUrl = 'https://downloads.php.net/~windows/php-sdk/deps'
2020
$phpTrunkBaseUrl = "https://downloads.php.net/~windows/php-sdk/deps/$($Config.vs_version)/$($Config.arch)"
21-
$phpSeries = Invoke-WebRequest -Uri "$phpBaseUrl/series/packages-$($Config.php_version)-$($Config.vs_version)-$($Config.arch)-staging.txt" -UseBasicParsing
22-
$phpTrunk = Invoke-WebRequest -Uri $phpTrunkBaseUrl -UseBasicParsing
21+
$phpSeries = Get-File -Url "$phpBaseUrl/series/packages-$($Config.php_version)-$($Config.vs_version)-$($Config.arch)-staging.txt"
22+
$phpTrunk = Get-File -Url $phpTrunkBaseUrl
2323
foreach ($library in $Config.php_libraries) {
2424
try {
2525
$matchesFound = $phpSeries.Content | Select-String -Pattern "(^|\n)$library.*"
@@ -35,7 +35,7 @@ Function Add-PhpDependencies {
3535
throw "Failed to find $library"
3636
}
3737
$file = $matchesFound.Matches[0].Value.Trim()
38-
Invoke-WebRequest "$phpBaseUrl/$($Config.vs_version)/$($Config.arch)/$file" -OutFile $library
38+
Get-File -Url "$phpBaseUrl/$($Config.vs_version)/$($Config.arch)/$file" -OutFile $library
3939
Expand-Archive $library "../deps"
4040
Add-BuildLog tick "$library" "Added $($file -replace '\.zip$')"
4141
} catch {

extension/BuildPhpExtension/private/Add-VS.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function Add-Vs {
3232
if (-not (Test-Path $installerDir)) {
3333
New-Item -Path $installerDir -ItemType Directory -Force | Out-Null
3434
}
35-
Invoke-WebRequest -Uri $vsWhereUrl -OutFile $vswherePath -UseBasicParsing
35+
Get-File -Url $vsWhereUrl -OutFile $vswherePath
3636
}
3737

3838
$instances = & $vswherePath -products '*' -format json 2> $null | ConvertFrom-Json
@@ -57,7 +57,7 @@ function Add-Vs {
5757
$installerUrl = "https://aka.ms/vs/$channel/release/$exe"
5858
$installerPath = Join-Path $env:TEMP $exe
5959

60-
Invoke-WebRequest -Uri $installerUrl -OutFile $installerPath -UseBasicParsing
60+
Get-File -Url $installerUrl -OutFile $installerPath
6161

6262
& $installerPath modify `
6363
--installPath $vsInst.installationPath `
@@ -69,7 +69,7 @@ function Add-Vs {
6969
$installerUrl = "https://aka.ms/vs/$channel/release/$exe"
7070
$installerPath = Join-Path $env:TEMP $exe
7171

72-
Invoke-WebRequest -Uri $installerUrl -OutFile $installerPath -UseBasicParsing
72+
Get-File -Url $installerUrl -OutFile $installerPath
7373
& $installerPath `
7474
--quiet --wait --norestart --nocache `
7575
@componentArgs 2>&1 | ForEach-Object { Write-Host $_ }

0 commit comments

Comments
 (0)