This repository was archived by the owner on Feb 23, 2021. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ $ErrorActionPreference = " Stop"
2+
3+ function DownloadWithRetry ([string ] $url , [string ] $downloadLocation , [int ] $retries )
4+ {
5+ while ($true )
6+ {
7+ try
8+ {
9+ Invoke-WebRequest $url - OutFile $downloadLocation
10+ break
11+ }
12+ catch
13+ {
14+ $exceptionMessage = $_.Exception.Message
15+ Write-Host " Failed to download '$url ': $exceptionMessage "
16+ if ($retries -gt 0 ) {
17+ $retries --
18+ Write-Host " Waiting 10 seconds before retrying. Retries left: $retries "
19+ Start-Sleep - Seconds 10
20+
21+ }
22+ else
23+ {
24+ $exception = $_.Exception
25+ throw $exception
26+ }
27+ }
28+ }
29+ }
30+
131cd $PSScriptRoot
232
333$repoFolder = $PSScriptRoot
@@ -20,7 +50,8 @@ if (!(Test-Path $buildFolder)) {
2050
2151 $localZipFile = " $tempFolder \korebuild.zip"
2252
23- Invoke-WebRequest $koreBuildZip - OutFile $localZipFile
53+ DownloadWithRetry - url $koreBuildZip - downloadLocation $localZipFile - retries 6
54+
2455 Add-Type - AssemblyName System.IO.Compression.FileSystem
2556 [System.IO.Compression.ZipFile ]::ExtractToDirectory($localZipFile , $tempFolder )
2657
Original file line number Diff line number Diff line change @@ -18,7 +18,18 @@ if test ! -d $buildFolder; then
1818
1919 localZipFile=" $tempFolder /korebuild.zip"
2020
21- wget -O $localZipFile $koreBuildZip 2> /dev/null || curl -o $localZipFile --location $koreBuildZip /dev/null
21+ retries=6
22+ until (wget -O $localZipFile $koreBuildZip 2> /dev/null || curl -o $localZipFile --location $koreBuildZip 2> /dev/null)
23+ do
24+ echo " Failed to download '$koreBuildZip '"
25+ if [ " $retries " -le 0 ]; then
26+ exit 1
27+ fi
28+ retries=$(( retries - 1 ))
29+ echo " Waiting 10 seconds before retrying. Retries left: $retries "
30+ sleep 10s
31+ done
32+
2233 unzip -q -d $tempFolder $localZipFile
2334
2435 mkdir $buildFolder
@@ -32,4 +43,4 @@ if test ! -d $buildFolder; then
3243 fi
3344fi
3445
35- $buildFile -r $repoFolder " $@ "
46+ $buildFile -r $repoFolder " $@ "
You can’t perform that action at this time.
0 commit comments