summaryrefslogtreecommitdiff
path: root/tools/build_scripts/fixme.cmd
blob: 82f7511e10265d8fef023a176cb0cf5335ad5672 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
@echo off

set ProfileDir=%~dp0Profiles

for /F "tokens=1,2 delims== " %%a in ('findstr "ProfileDir=" mirandaboot.ini') do (
  set ProfileDir=%%b
)

echo Using profile directory %ProfileDir%

if "%1" == "" (
  pushd "%ProfileDir%"

  for /D %%i in (*) do (
    if exist "%%i\%%i.dat" set ProfileName=%%i
  )

  popd

  if "%ProfileName%" == "" (
     echo No default profile found, exiting
     goto :eof
  )

) else (
  if not exist "%ProfileDir%\%1\%1.dat" (
    echo Wrong profile name specified: %1
    goto :eof
  )

  set ProfileName=%1
)

echo Backing up %ProfileName%...

set FullProfileName=%ProfileDir%\%ProfileName%\%ProfileName%.dat
set TmpFileName=%TEMP%\%ProfileName%.tmp

del "%TmpFileName%" > nul

mdbx_dump.exe -n -a -f "%TmpFileName%" "%FullProfileName%"
if not exist "%TmpFileName%" (
  echo Backup failed, exiting
  goto :eof
)

mdbx_load.exe -n -f "%TmpFileName%" "%FullProfileName%.tmp"
if errorlevel 1 (
  echo Restore failed, exiting
  goto :eof
)

del "%FullProfileName%.bak" > nul
move "%FullProfileName%" "%FullProfileName%.bak"
move "%FullProfileName%.tmp" "%FullProfileName%"

echo Operation succeeded
goto :eof