@echo off
setlocal EnableExtensions
chcp 65001 >nul
cd /d "%~dp0"
title OnlyCoin - Veritabani Kurtarma

call "%CD%\scripts\resolve-node.cmd"
if errorlevel 1 goto :failed

echo.
echo =========================================================
echo ONLYCOIN VERITABANI KURTARMA
echo =========================================================
echo 1 - Saglik kontrolu ve saglamsa dogrulanmis yedek al
echo 2 - Dogrulanmis bir yedegi geri yukle
echo 3 - Bozuk dosyalari silmeden recovery klasorune karantinaya al
echo.
set /p CHOICE=Seciminiz (1/2/3):

if "%CHOICE%"=="1" goto :check
if "%CHOICE%"=="2" goto :restore
if "%CHOICE%"=="3" goto :quarantine
exit /b 0

:check
"%NODE_EXE%" --no-warnings "%CD%\scripts\repair-database.js"
goto :done

:restore
set /p BACKUP=Geri yuklenecek .db yedeginin tam yolu:
if "%BACKUP%"=="" exit /b 0
"%NODE_EXE%" --no-warnings "%CD%\scripts\repair-database.js" --restore="%BACKUP%" --confirm=GERI-YUKLE
goto :done

:quarantine
echo.
echo UYARI: Bu islem mevcut DB/WAL/SHM dosyalarini data\recovery altina tasir.
echo Canli kurulumda daha sonra dogrulanmis bir yedek geri yuklenmelidir.
set /p CONFIRM=Devam etmek icin KARANTINA yazin:
if /I not "%CONFIRM%"=="KARANTINA" exit /b 0
"%NODE_EXE%" --no-warnings "%CD%\scripts\repair-database.js" --quarantine --confirm=KARANTINA
goto :done

:done
if errorlevel 1 goto :failed
pause
exit /b 0

:failed
echo.
echo Veritabani islemi basarisiz oldu.
echo TANI-WINDOWS.bat dosyasini calistirip raporu inceleyin.
pause
exit /b 1
