Introduce versioning on main configuration file

This commit is contained in:
Chocobo1 2021-12-05 12:43:42 +08:00
parent cbc2de6b85
commit b8a7ecfe69
No known key found for this signature in database
GPG key ID: 210D9C873253A68C
2 changed files with 22 additions and 8 deletions

View file

@ -36,12 +36,15 @@
#include "base/preferences.h"
#include "base/profile.h"
#include "base/settingsstorage.h"
#include "base/settingvalue.h"
#include "base/utils/fs.h"
#include "base/utils/io.h"
#include "base/utils/string.h"
namespace
{
const int MIGRATION_VERSION = 1;
void exportWebUIHttpsFiles()
{
const auto migrate = [](const QString &oldKey, const QString &newKey, const QString &savePath)
@ -228,6 +231,12 @@ namespace
}
bool upgrade(const bool /*ask*/)
{
CachedSettingValue<int> version {"Meta/MigrationVersion", 0};
if (version != MIGRATION_VERSION)
{
if (version < 1)
{
exportWebUIHttpsFiles();
upgradeTorrentContentLayout();
@ -235,6 +244,11 @@ bool upgrade(const bool /*ask*/)
upgradeSchedulerDaysSettings();
upgradeDNSServiceSettings();
upgradeTrayIconStyleSettings();
}
version = MIGRATION_VERSION;
}
return true;
}

View file

@ -146,9 +146,9 @@ namespace Utils
{
return Version(s);
}
catch (const RuntimeError &er)
catch (const RuntimeError &error)
{
qDebug() << "Error parsing version:" << er.message();
qDebug() << "Error parsing version:" << error.message();
return defaultVersion;
}
}