Skip to content

Commit 023f1b8

Browse files
committed
Fix Get-File [skip ci]
1 parent ab655c2 commit 023f1b8

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed

scripts/Get-Php.ps1

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,33 @@ Function Get-File {
3131
param (
3232
[string]$Url,
3333
[string]$FallbackUrl,
34-
[string]$OutFile,
34+
[string]$OutFile = '',
3535
[int]$Retries = 3,
3636
[int]$TimeoutSec = 0
3737
)
3838

3939
for ($i = 0; $i -lt $Retries; $i++) {
4040
try {
41-
if($null -ne $OutFile) {
41+
if($OutFile -ne '') {
4242
Invoke-WebRequest -Uri $Url -OutFile $OutFile -TimeoutSec $TimeoutSec
4343
} else {
4444
Invoke-WebRequest -Uri $Url -TimeoutSec $TimeoutSec
4545
}
4646
break;
4747
} catch {
48-
if ($i -eq ($Retries - 1) -and ($null -ne $FallbackUrl)) {
49-
try {
50-
if($null -ne $OutFile) {
51-
Invoke-WebRequest -Uri $FallbackUrl -OutFile $OutFile -TimeoutSec $TimeoutSec
52-
} else {
53-
Invoke-WebRequest -Uri $FallbackUrl -TimeoutSec $TimeoutSec
48+
if ($i -eq ($Retries - 1)) {
49+
if($FallbackUrl) {
50+
try {
51+
if($OutFile -ne '') {
52+
Invoke-WebRequest -Uri $FallbackUrl -OutFile $OutFile -TimeoutSec $TimeoutSec
53+
} else {
54+
Invoke-WebRequest -Uri $FallbackUrl -TimeoutSec $TimeoutSec
55+
}
56+
} catch {
57+
throw "Failed to download the assets from $Url and $FallbackUrl"
5458
}
55-
} catch {
56-
throw "Failed to download the build"
59+
} else {
60+
throw "Failed to download the assets from $Url"
5761
}
5862
}
5963
}

scripts/Get-PhpNightly.ps1

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,33 @@ Function Get-File {
3131
param (
3232
[string]$Url,
3333
[string]$FallbackUrl,
34-
[string]$OutFile,
34+
[string]$OutFile = '',
3535
[int]$Retries = 3,
3636
[int]$TimeoutSec = 0
3737
)
3838

3939
for ($i = 0; $i -lt $Retries; $i++) {
4040
try {
41-
if($null -ne $OutFile) {
41+
if($OutFile -ne '') {
4242
Invoke-WebRequest -Uri $Url -OutFile $OutFile -TimeoutSec $TimeoutSec
4343
} else {
4444
Invoke-WebRequest -Uri $Url -TimeoutSec $TimeoutSec
4545
}
4646
break;
4747
} catch {
48-
if ($i -eq ($Retries - 1) -and ($null -ne $FallbackUrl)) {
49-
try {
50-
if($null -ne $OutFile) {
51-
Invoke-WebRequest -Uri $FallbackUrl -OutFile $OutFile -TimeoutSec $TimeoutSec
52-
} else {
53-
Invoke-WebRequest -Uri $FallbackUrl -TimeoutSec $TimeoutSec
48+
if ($i -eq ($Retries - 1)) {
49+
if($FallbackUrl) {
50+
try {
51+
if($OutFile -ne '') {
52+
Invoke-WebRequest -Uri $FallbackUrl -OutFile $OutFile -TimeoutSec $TimeoutSec
53+
} else {
54+
Invoke-WebRequest -Uri $FallbackUrl -TimeoutSec $TimeoutSec
55+
}
56+
} catch {
57+
throw "Failed to download the assets from $Url and $FallbackUrl"
5458
}
55-
} catch {
56-
throw "Failed to download the build"
59+
} else {
60+
throw "Failed to download the assets from $Url"
5761
}
5862
}
5963
}

0 commit comments

Comments
 (0)