Update Lexilla to 5.1.8
[TortoiseGit.git] / ext / putty / download.bat
blobd108824c27c4bc446fcb70816a56a4efd5f0e17f
1 @echo off\r
2 SETLOCAL ENABLEDELAYEDEXPANSION\r
3 pushd %~dp0\r
4 \r
5 rem recheck whether we need to re-download\r
6 certUtil -hashfile download.txt sha256 > lastrun.tmp\r
7 fc /C lastrun.tmp lastrun.txt || (\r
8   del lastrun.txt\r
9   move lastrun.tmp lastrun.txt\r
10   set needsupdate=1\r
11 )\r
12 del lastrun.tmp\r
14 rem do the download and checks\r
15 for /F "tokens=1-3" %%a in (download.txt) do (\r
16   echo %%a\r
17   if "%needsupdate%"=="1" del "%%b"\r
18   if not exist "%%b" (\r
19     set LOCALFILENAME="%%b.tmp"\r
20     del !LOCALFILENAME!\r
21     curl --fail-early --output !LOCALFILENAME! "%%a" || (\r
22       echo "Download of %%a failed."\r
23       goto error\r
24     )\r
25   ) else (\r
26     set LOCALFILENAME="%%b"\r
27   )\r
28   if not exist !LOCALFILENAME! (\r
29     echo "File !LOCALFILENAME! is missing."\r
30     goto error\r
31   )\r
32   if "%%c"=="" goto error\r
33   certUtil -hashfile !LOCALFILENAME! sha256 | findstr /I %%c > findstroutput.tmp\r
34   echo %%c> wantedhash.tmp\r
35   fc /C wantedhash.tmp findstroutput.tmp && (\r
36     if NOT !LOCALFILENAME!=="%%b" move "!LOCALFILENAME!" "%%b"\r
37     del findstroutput.tmp wantedhash.tmp\r
38   ) || (\r
39     echo "Invalid hash for !LOCALFILENAME! found!"\r
40     del !LOCALFILENAME! findstroutput.tmp wantedhash.tmp\r
41     goto error\r
42   )\r
43 )\r
45 popd\r
46 goto :eof\r
48 :error\r
49 popd\r
50 pause\r
51 exit /b 1\r