From 7803da6806396147030efb7e2ed881cebd90cfef Mon Sep 17 00:00:00 2001 From: "Dariy.Nurgaleev" Date: Thu, 19 Mar 2020 18:15:11 +0700 Subject: [PATCH] added DownloadWithRetry function --- .../scripts/ImageHelpers/InstallHelpers.ps1 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/images/win/scripts/ImageHelpers/InstallHelpers.ps1 b/images/win/scripts/ImageHelpers/InstallHelpers.ps1 index 201dea865..5ce11dede 100644 --- a/images/win/scripts/ImageHelpers/InstallHelpers.ps1 +++ b/images/win/scripts/ImageHelpers/InstallHelpers.ps1 @@ -161,15 +161,17 @@ Hashtable for service arguments } } - function Start-DownloadWithRetry { param ( - [Parameter(Mandatory)] - [string] $Url, - [string] $FullFilePath = "${env:Temp}\Default.exe", - [int] $retries = 20 - ) + [Parameter(Mandatory)] + [string] $Url, + [string] $DownloadPath = "${env:Temp}", + [Parameter(Mandatory)] + [string] $Name, + [int] $retries = 20 + ) + $FilePath = Join-Path $DownloadPath "\" $Name #Default retry logic for the package. while($retries -gt 0) { @@ -183,7 +185,6 @@ function Start-DownloadWithRetry { Write-Host "There is an error during package downloading" $_ - $retries-- if ($retries -eq 0) @@ -192,12 +193,11 @@ function Start-DownloadWithRetry $_ exit 1 } - Write-Host "Waiting 30 seconds before retrying. Retries left: $retries" Start-Sleep -Seconds 30 } } - return $FullFilePath + return $FilePath }