Skip to content

Commit f1f4071

Browse files
committed
Added additional update check in case file already exists
This is especially useful in case of force updates, where the most up-to-date file may already exist
1 parent ef01cd1 commit f1f4071

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

b-e updater.bat

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ if /i "%1"=="--silent" (
5656

5757
:Update
5858
cls
59+
if exist "batch encoder %UpdateVersion%%append%-u.bat" (del "batch encoder %UpdateVersion%%append%-u.bat")
5960
echo %icongray% i %formatend% Downloading information...
6061
set "updateFileName=batch_update.json"
6162
curl --silent -L -H "Accept: application/vnd.github+json" -o %updateFileName% https://api.github.com/repos/Adam-Kay/Batch-Encoder/releases/latest
@@ -79,17 +80,18 @@ if /i "%1"=="--silent" (
7980
echo.
8081
timeout /nobreak /t 5 > nul
8182
echo Downloading files...
82-
curl --silent -L -H "Accept: application/octet-stream" -o "batch encoder %UpdateVersion%.bat" %UpdateAPIURL%
83+
curl --silent -L -H "Accept: application/octet-stream" -o "batch encoder %UpdateVersion%-u.bat" %UpdateAPIURL%
8384
echo.
84-
if not exist "batch encoder %UpdateVersion%.bat" (
85+
if not exist "batch encoder %UpdateVersion%-u.bat" (
8586
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+
curl --silent --ssl-no-revoke -L -H "Accept: application/octet-stream" -o "batch encoder %UpdateVersion%-u.bat" %UpdateAPIURL%
8788
echo.
88-
if not exist "batch encoder %UpdateVersion%.bat" (
89+
if not exist "batch encoder %UpdateVersion%-u.bat" (
8990
echo %iconred% ^^! %formatend% Alternate download failed.
9091
goto AutoUpdateError
9192
)
9293
)
94+
move /Y "batch encoder %UpdateVersion%%append%-u.bat" "batch encoder %UpdateVersion%%append%.bat" > nul
9395
if "%par_silent%"=="true" (
9496
echo %icongreen% i %formatend% Download complete. The program will now clean up and exit.
9597
) else (

batch encoder.bat

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ if defined par_updated-from (
7575

7676
:AutoUpdate
7777
call:ClearAndTitle
78+
if exist "batch encoder %UpdateVersion%%append%-u.bat" (del "batch encoder %UpdateVersion%%append%-u.bat")
7879
echo %icongray% i %formatend% Downloading information...
7980
set "updateFileName=batch_update.json"
8081
curl --silent -L -H "Accept: application/vnd.github+json" -o %updateFileName% https://api.github.com/repos/Adam-Kay/Batch-Encoder/releases/latest
@@ -119,17 +120,18 @@ if defined par_updated-from (
119120
echo.
120121
timeout /nobreak /t 5 > nul
121122
echo Downloading files...
122-
curl --silent -L -H "Accept: application/octet-stream" -o "batch encoder %UpdateVersion%%append%.bat" %UpdateAPIURL%
123+
curl --silent -L -H "Accept: application/octet-stream" -o "batch encoder %UpdateVersion%%append%-u.bat" %UpdateAPIURL%
123124
echo.
124-
if not exist "batch encoder %UpdateVersion%%append%.bat" (
125+
if not exist "batch encoder %UpdateVersion%%append%-u.bat" (
125126
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+
curl --silent --ssl-no-revoke -L -H "Accept: application/octet-stream" -o "batch encoder %UpdateVersion%%append%-u.bat" %UpdateAPIURL%
127128
echo.
128-
if not exist "batch encoder %UpdateVersion%%append%.bat" (
129+
if not exist "batch encoder %UpdateVersion%%append%-u.bat" (
129130
echo %iconred% ^^! %formatend% Alternate download failed.
130131
goto AutoUpdateError
131132
)
132133
)
134+
move /Y "batch encoder %UpdateVersion%%append%-u.bat" "batch encoder %UpdateVersion%%append%.bat" > nul
133135
echo %icongreen% i %formatend% Download complete. The program will now clean up and restart.
134136
call:GrayPause
135137
del "%updateFileName%"

0 commit comments

Comments
 (0)