Skip to content

Commit ef01cd1

Browse files
committed
Added updater check and backup. Closes #31
Also closes #20. Introduces backup download which skips SSL checks. See #31 for details.
1 parent b054f6b commit ef01cd1

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

b-e updater.bat

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ setlocal enabledelayedexpansion
44
set "icongray="
55
set "iconyellow="
66
set "icongreen="
7+
set "iconred="
78
set "textgray="
89
set "textgreen="
910
set "textred="
@@ -58,7 +59,7 @@ if /i "%1"=="--silent" (
5859
echo %icongray% i %formatend% Downloading information...
5960
set "updateFileName=batch_update.json"
6061
curl --silent -L -H "Accept: application/vnd.github+json" -o %updateFileName% https://api.github.com/repos/Adam-Kay/Batch-Encoder/releases/latest
61-
rem curl --silent -o batch_update.txt https://gist.githubusercontent.com/Adam-Kay/ec5da0ff40e8eb14beee2242161f5191/raw
62+
if not exist "%updateFileName%" (goto AutoUpdateError)
6263

6364
>%TEMP%\batch_update.tmp findstr "tag_name" %updateFileName%
6465
<%TEMP%\batch_update.tmp set /p "ver_entry="
@@ -80,6 +81,15 @@ if /i "%1"=="--silent" (
8081
echo Downloading files...
8182
curl --silent -L -H "Accept: application/octet-stream" -o "batch encoder %UpdateVersion%.bat" %UpdateAPIURL%
8283
echo.
84+
if not exist "batch encoder %UpdateVersion%.bat" (
85+
echo %iconred% ^^! %formatend% Download failed. & echo. & echo Attempting alternate download...
86+
curl --silent --ssl-no-revoke -L -H "Accept: application/octet-stream" -o "batch encoder %UpdateVersion%.bat" %UpdateAPIURL%
87+
echo.
88+
if not exist "batch encoder %UpdateVersion%.bat" (
89+
echo %iconred% ^^! %formatend% Alternate download failed.
90+
goto AutoUpdateError
91+
)
92+
)
8393
if "%par_silent%"=="true" (
8494
echo %icongreen% i %formatend% Download complete. The program will now clean up and exit.
8595
) else (

batch encoder.bat

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ cls
77
set "icongray="
88
set "iconyellow="
99
set "icongreen="
10+
set "iconred="
1011
set "textgray="
1112
set "textgreen="
1213
set "textred="
@@ -77,6 +78,7 @@ if defined par_updated-from (
7778
echo %icongray% i %formatend% Downloading information...
7879
set "updateFileName=batch_update.json"
7980
curl --silent -L -H "Accept: application/vnd.github+json" -o %updateFileName% https://api.github.com/repos/Adam-Kay/Batch-Encoder/releases/latest
81+
if not exist "%updateFileName%" (goto AutoUpdateError)
8082

8183
>%TEMP%\batch_update.tmp findstr "tag_name" %updateFileName%
8284
<%TEMP%\batch_update.tmp set /p "ver_entry="
@@ -119,6 +121,15 @@ if defined par_updated-from (
119121
echo Downloading files...
120122
curl --silent -L -H "Accept: application/octet-stream" -o "batch encoder %UpdateVersion%%append%.bat" %UpdateAPIURL%
121123
echo.
124+
if not exist "batch encoder %UpdateVersion%%append%.bat" (
125+
echo %iconred% ^^! %formatend% Download failed. & echo. & echo Attempting alternate download...
126+
curl --silent --ssl-no-revoke -L -H "Accept: application/octet-stream" -o "batch encoder %UpdateVersion%%append%.bat" %UpdateAPIURL%
127+
echo.
128+
if not exist "batch encoder %UpdateVersion%%append%.bat" (
129+
echo %iconred% ^^! %formatend% Alternate download failed.
130+
goto AutoUpdateError
131+
)
132+
)
122133
echo %icongreen% i %formatend% Download complete. The program will now clean up and restart.
123134
call:GrayPause
124135
del "%updateFileName%"

0 commit comments

Comments
 (0)