From c61bd0e074432388364abd3629b111a5da147da4 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Mon, 3 Apr 2023 00:03:00 +0530 Subject: [PATCH] Fix Get-File in win32.ps1 --- src/scripts/win32.ps1 | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/scripts/win32.ps1 b/src/scripts/win32.ps1 index 6b1e2d926..b780d83bf 100644 --- a/src/scripts/win32.ps1 +++ b/src/scripts/win32.ps1 @@ -147,15 +147,19 @@ Function Get-File { } break; } catch { - if ($i -eq ($Retries - 1) -and ($null -ne $FallbackUrl)) { - try { - if($null -ne $OutFile) { - Invoke-WebRequest -Uri $FallbackUrl -OutFile $OutFile -TimeoutSec $TimeoutSec - } else { - Invoke-WebRequest -Uri $FallbackUrl -TimeoutSec $TimeoutSec + if ($i -eq ($Retries - 1)) { + if($FallbackUrl) { + try { + if($null -ne $OutFile) { + Invoke-WebRequest -Uri $FallbackUrl -OutFile $OutFile -TimeoutSec $TimeoutSec + } else { + Invoke-WebRequest -Uri $FallbackUrl -TimeoutSec $TimeoutSec + } + } catch { + throw "Failed to download the assets from $Url and $FallbackUrl" } - } catch { - throw "Failed to download the assets from $Url and $FallbackUrl" + } else { + throw "Failed to download the assets from $Url" } } }