mirror of
https://github.com/tnodir/fort
synced 2024-11-15 08:25:20 +00:00
UI: FortSettings: Simplify .conf saving.
This commit is contained in:
parent
94347ef144
commit
272ecde7fe
@ -192,33 +192,18 @@ bool FortSettings::writeConf(const FirewallConf &conf)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!tryToWriteConf(conf, backupFilePath)) {
|
||||
setErrorMessage(tr("Can't create backup .conf file"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!FileUtil::removeFile(filePath)) {
|
||||
setErrorMessage(tr("Can't remove .conf file"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!FileUtil::copyFile(backupFilePath, filePath)) {
|
||||
setErrorMessage(tr("Can't create .conf file"));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FortSettings::tryToWriteConf(const FirewallConf &conf, const QString &filePath)
|
||||
{
|
||||
const QJsonDocument jsonDoc = QJsonDocument::fromVariant(
|
||||
conf.toVariant());
|
||||
|
||||
const QByteArray data = jsonDoc.toJson(QJsonDocument::Indented);
|
||||
|
||||
if (!FileUtil::writeFileData(backupFilePath, data)) {
|
||||
setErrorMessage(tr("Can't create backup .conf file"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!FileUtil::writeFileData(filePath, data)) {
|
||||
setErrorMessage(tr("Can't write .conf file"));
|
||||
setErrorMessage(tr("Can't create .conf file"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,6 @@ private:
|
||||
QString confBackupFilePath() const;
|
||||
|
||||
bool tryToReadConf(FirewallConf &conf, const QString &filePath);
|
||||
bool tryToWriteConf(const FirewallConf &conf, const QString &filePath);
|
||||
|
||||
QVariant migrateConf(const QVariant &confVar);
|
||||
void removeMigratedKeys();
|
||||
|
Binary file not shown.
@ -84,26 +84,16 @@
|
||||
<source>Can't write .ini file</source>
|
||||
<translation>Не удалось записать .ini файл</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../fortsettings.cpp" line="201"/>
|
||||
<source>Can't remove .conf file</source>
|
||||
<translation>Не удалось удалить .conf файл</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../fortsettings.cpp" line="206"/>
|
||||
<source>Can't create .conf file</source>
|
||||
<translation>Не удалось создать .conf файл</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../fortsettings.cpp" line="196"/>
|
||||
<location filename="../fortsettings.cpp" line="201"/>
|
||||
<source>Can't create backup .conf file</source>
|
||||
<translation>Не удалось создать бэкап .conf файла</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../fortsettings.cpp" line="221"/>
|
||||
<source>Can't write .conf file</source>
|
||||
<translation>Не удалось записать .conf файл</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Ip4Range</name>
|
||||
|
Loading…
Reference in New Issue
Block a user