This repository was archived by the owner on Dec 28, 2017. It is now read-only.
File tree 2 files changed +45
-3
lines changed
2 files changed +45
-3
lines changed 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
+
1
31
cd $PSScriptRoot
2
32
3
33
$repoFolder = $PSScriptRoot
@@ -20,7 +50,8 @@ if (!(Test-Path $buildFolder)) {
20
50
21
51
$localZipFile = " $tempFolder \korebuild.zip"
22
52
23
- Invoke-WebRequest $koreBuildZip - OutFile $localZipFile
53
+ DownloadWithRetry - url $koreBuildZip - downloadLocation $localZipFile - retries 6
54
+
24
55
Add-Type - AssemblyName System.IO.Compression.FileSystem
25
56
[System.IO.Compression.ZipFile ]::ExtractToDirectory($localZipFile , $tempFolder )
26
57
Original file line number Diff line number Diff line change @@ -18,7 +18,18 @@ if test ! -d $buildFolder; then
18
18
19
19
localZipFile=" $tempFolder /korebuild.zip"
20
20
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
+
22
33
unzip -q -d $tempFolder $localZipFile
23
34
24
35
mkdir $buildFolder
@@ -32,4 +43,4 @@ if test ! -d $buildFolder; then
32
43
fi
33
44
fi
34
45
35
- $buildFile -r $repoFolder " $@ "
46
+ $buildFile -r $repoFolder " $@ "
You can’t perform that action at this time.
0 commit comments