Initial: flux text FoxBin2Prg (git urmareste .??2 in-arbore, binarele VFP git-ignored)
Include si sistemul de depanare/testare headless din Teste\ (harness UI cu capturi, verificare de sintaxa prin compilare, wrappere text<->binar) si docs\depanare_testare_flora2roa.md.
This commit is contained in:
109
update.bat
Normal file
109
update.bat
Normal file
@@ -0,0 +1,109 @@
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
:: Set the variables
|
||||
set DOWNLOAD_URL=https://roa.romfast.ro/contafinupdate/default.aspx/update/download/1/
|
||||
|
||||
set APP_NAME=flora2roa
|
||||
set APP_DIR=%~dp0
|
||||
set CURRENT_VERSION_FILE=%APP_NAME%.txt
|
||||
set SERVER_VERSION_FILE=%APP_NAME%.txt
|
||||
set NEW_VERSION_FILE=%APP_NAME%_server.txt
|
||||
set UPDATE_FILE=%APP_NAME%.zip
|
||||
|
||||
set UNZIP_DIR=%APP_DIR%\unzip
|
||||
set APP_EXE=%APP_NAME%.exe
|
||||
set APP_EXE_OLD=%APP_NAME%_old.exe
|
||||
set LOG_FILE=%APP_DIR%update_log.txt
|
||||
|
||||
:: Log the variables for debugging
|
||||
echo [%date% %time%] APP_DIR=%APP_DIR% >> %LOG_FILE%
|
||||
echo [%date% %time%] LOG_FILE=%LOG_FILE% >> %LOG_FILE%
|
||||
echo [%date% %time%] UNZIP_DIR=%UNZIP_DIR% >> %LOG_FILE%
|
||||
|
||||
echo [%date% %time%] Start actualizare >> %LOG_FILE%
|
||||
|
||||
CD %APP_DIR%
|
||||
|
||||
:: Check the current version
|
||||
if not exist "%CURRENT_VERSION_FILE%" (
|
||||
echo [%date% %time%] Current version file not found. >> %LOG_FILE%
|
||||
echo 0.0.0 >> %APP_DIR%\%CURRENT_VERSION_FILE%
|
||||
)
|
||||
|
||||
set /p CURRENT_VERSION=<"%CURRENT_VERSION_FILE%"
|
||||
|
||||
echo [%date% %time%] current version %CURRENT_VERSION_FILE%: %CURRENT_VERSION% >> %LOG_FILE%
|
||||
|
||||
:: Get the new version from the server
|
||||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%DOWNLOAD_URL%%SERVER_VERSION_FILE%', '%APP_DIR%\%NEW_VERSION_FILE%')" || (
|
||||
echo [%date% %time%] Error: Failed to download new version file: %DOWNLOAD_URL%%SERVER_VERSION_FILE% >> %LOG_FILE%
|
||||
goto END
|
||||
)
|
||||
|
||||
set /p NEW_VERSION=<"%APP_DIR%\%NEW_VERSION_FILE%"
|
||||
|
||||
echo [%date% %time%] server version: %NEW_VERSION% >> %LOG_FILE%
|
||||
|
||||
:: Check if an update is available
|
||||
if "%CURRENT_VERSION%" geq "%NEW_VERSION%" (
|
||||
echo [%date% %time%] No update available. >> %LOG_FILE%
|
||||
goto END
|
||||
)
|
||||
|
||||
:: Download the update
|
||||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%DOWNLOAD_URL%%UPDATE_FILE%', '%APP_DIR%\%UPDATE_FILE%')" || (
|
||||
echo [%date% %time%] Error: Failed to download update file. >> %LOG_FILE%
|
||||
goto END
|
||||
)
|
||||
|
||||
:: Check if the application is running
|
||||
tasklist /fi "imagename eq %APP_EXE%" | find /i "%APP_EXE%" > nul
|
||||
if %errorlevel% equ 0 (
|
||||
echo [%date% %time%] Error: %APP_NAME% is currently running. Please close it before updating. >> %LOG_FILE%
|
||||
goto END
|
||||
)
|
||||
|
||||
:: Unzip the update
|
||||
powershell -Command "Expand-Archive -Path '%APP_DIR%\%UPDATE_FILE%' -DestinationPath '%UNZIP_DIR%' -Force" || (
|
||||
echo [%date% %time%] Error: Failed to unzip update file. >> %LOG_FILE%
|
||||
goto END
|
||||
)
|
||||
|
||||
:: Update the application
|
||||
if exist "%APP_DIR%\%APP_EXE_OLD%" (
|
||||
del "%APP_DIR%\%APP_EXE_OLD%"
|
||||
echo [%date% %time%] Fișierul %APP_DIR%\%APP_EXE_OLD% a fost șters >> %LOG_FILE%
|
||||
)
|
||||
|
||||
if not exist "%UNZIP_DIR%\%APP_EXE%" (
|
||||
echo [%date% %time%] Nu exista fișierul %UNZIP_DIR%\%APP_EXE% >> %LOG_FILE%
|
||||
goto END
|
||||
)
|
||||
|
||||
if exist "%APP_DIR%\%APP_EXE%" (
|
||||
rename "%APP_DIR%\%APP_EXE%" "%APP_EXE_OLD%"
|
||||
echo [%date% %time%] Fișierul %APP_DIR%\%APP_EXE% a fost redenumit în %APP_DIR%\%APP_EXE_OLD% >> %LOG_FILE%
|
||||
)
|
||||
|
||||
move /y "%UNZIP_DIR%\%APP_EXE%" "%APP_DIR%\%APP_EXE%"
|
||||
|
||||
echo [%date% %time%] Updating %APP_DIR%\%APP_NAME% to version %NEW_VERSION%... >> %LOG_FILE%
|
||||
|
||||
:: Update the local version file
|
||||
if exist "%APP_DIR%\%CURRENT_VERSION_FILE%" (
|
||||
del "%APP_DIR%\%CURRENT_VERSION_FILE%"
|
||||
echo Fișierul %CURRENT_VERSION_FILE% a fost șters. >> %LOG_FILE%
|
||||
)
|
||||
|
||||
if exist "%APP_DIR%\%NEW_VERSION_FILE%" (
|
||||
rename "%APP_DIR%\%NEW_VERSION_FILE%" "%CURRENT_VERSION_FILE%"
|
||||
echo Fișierul %APP_DIR%\%NEW_VERSION_FILE% a fost redenumit în %CURRENT_VERSION_FILE%. >> %LOG_FILE%
|
||||
) else (
|
||||
echo Fișierul %APP_DIR%\%NEW_VERSION_FILE% nu a fost găsit. >> %LOG_FILE%
|
||||
)
|
||||
|
||||
echo [%date% %time%] Update successful. >> %LOG_FILE%
|
||||
|
||||
:END
|
||||
start "" "%APP_DIR%\%APP_EXE%"
|
||||
exit /b
|
||||
Reference in New Issue
Block a user