This commit is contained in:
2025-11-07 01:31:19 +03:00
parent fd8fcd5c1d
commit e79186cb4f
3 changed files with 12 additions and 5 deletions

View File

@@ -166,7 +166,7 @@ bool DataBaseLMS::createDB()
if(prepareRestoreDBscript())
{
QProcess process;
QString pgRestorePath = "restoreDBscript.bat";
QString pgRestorePath = restoreDBscriptName;
process.start("cmd /C " + pgRestorePath);
process.waitForFinished(-1); // Ждать бесконечно, пока процесс не завершится
@@ -235,17 +235,18 @@ bool DataBaseLMS::prepareRestoreDBscript()
{
DataBaseSettings settings = getDataBaseSettings();
QFile file("restoreDBscript.bat");
QFile file(restoreDBscriptName);
if (file.open(QIODevice::WriteOnly | QIODevice::Text))
{
QTextStream out(&file);
out << "set CURRENT_DIR=%~dp0\n";
out << "cd %CURRENT_DIR%\n";
out << QString("set \"PGPASSWORD=%1\"\n").arg(PasswordPostgres);
out << QString("pg_restore -U %1 -h %2 -p %3 -d %4 DBLMS_EMPTY.backup\n").arg(UserNamePostgres,
out << QString("pg_restore -U %1 -h %2 -p %3 -d %4 %5\n").arg(UserNamePostgres,
settings.dbHostName,
QString::number(settings.dbPort),
settings.dbName);
settings.dbName,
backupEmptyName);
file.close();
return true;
}