11$ErrorActionPreference = ' Stop'
22
3+ function Invoke-DownloadWithRetry {
4+ param ([string ]$Uri , [string ]$OutFile , [int ]$MaxRetries = 10 , [int ]$RetryDelay = 30 )
5+ for ($i = 1 ; $i -le ($MaxRetries + 1 ); $i ++ ) {
6+ try {
7+ Invoke-WebRequest $Uri - OutFile $OutFile
8+ return
9+ } catch {
10+ if ($i -gt $MaxRetries ) { throw }
11+ Write-Host " Download failed (attempt $i of $ ( $MaxRetries + 1 ) ), retrying in $RetryDelay seconds..."
12+ Start-Sleep - Seconds $RetryDelay
13+ }
14+ }
15+ }
16+
317# switch to a temp directory
418cd $env: TEMP
519[Environment ]::CurrentDirectory = $PWD.Path
@@ -11,18 +25,18 @@ $TLREPO = if ($env:CTAN_REPO) { $env:CTAN_REPO } else { 'https://tlnet.yihui.org
1125$TLURL = " $TLREPO /install-tl.zip"
1226
1327# download install-tl.zip and unzip it
14- Invoke-WebRequest $TLURL - OutFile install-tl .zip
28+ Invoke-DownloadWithRetry $TLURL install-tl .zip
1529Add-Type - A ' System.IO.Compression.FileSystem'
1630[IO.Compression.ZipFile ]::ExtractToDirectory(' install-tl.zip' , ' .' )
1731del install-tl .zip
1832
1933# download tinytex.profile and modify it (set texdir to ./TinyTeX)
20- Invoke-WebRequest ' https://tinytex.yihui.org/tinytex.profile' - OutFile tinytex.profile
34+ Invoke-DownloadWithRetry ' https://tinytex.yihui.org/tinytex.profile' tinytex.profile
2135Add-Content tinytex.profile ' TEXMFCONFIG $TEXMFSYSCONFIG'
2236Add-Content tinytex.profile ' TEXMFVAR $TEXMFSYSVAR'
2337
2438# download the custom package list
25- Invoke-WebRequest ' https://tinytex.yihui.org/pkgs-custom.txt' - OutFile pkgs- custom.txt
39+ Invoke-DownloadWithRetry ' https://tinytex.yihui.org/pkgs-custom.txt' pkgs- custom.txt
2640
2741# an automated installation of TeX Live (infrastructure only)
2842cd install-tl -*
0 commit comments