summaryrefslogtreecommitdiff
path: root/tools/build_scripts/fixme.cmd
blob: 33f07dfe876de2ddd94b3c10bf6f8511ed727386 (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
@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 "%ProfileDir%\%%i\%%i.dat" (
      set ProfileName=%%i
    )
  )

  popd

) 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