Fixed #70.
This commit is contained in:
parent
ce57ed6d9a
commit
211494a1d8
6 changed files with 39 additions and 6 deletions
|
@ -2,6 +2,7 @@
|
|||
—————
|
||||
|
||||
Added:
|
||||
▪ User now can select if DB transactions are enabled or not. (bug #70)
|
||||
▪ MySQL database backend now requires at least version 5.5, DB encoding is now changed to utf8mb4 character set. (bug #74)
|
||||
▪ Height if message attachment image is now configurable, defaults to 36. (issue #69)
|
||||
▪ All textual contents of all messages are now locally saved in explicit UTF-8 encoding. This is partially because of MySQL backend. We need to keep encoding of data sent to DB and encoding of DB itself in parity.
|
||||
|
|
|
@ -32,6 +32,7 @@ SettingsDatabase::SettingsDatabase(Settings *settings, QWidget *parent)
|
|||
connect(m_ui->m_txtMysqlDatabase->lineEdit(), &QLineEdit::textChanged, this, &SettingsDatabase::dirtifySettings);
|
||||
connect(m_ui->m_txtMysqlHostname->lineEdit(), &QLineEdit::textChanged, this, &SettingsDatabase::dirtifySettings);
|
||||
connect(m_ui->m_txtMysqlPassword->lineEdit(), &QLineEdit::textChanged, this, &SettingsDatabase::dirtifySettings);
|
||||
connect(m_ui->m_checkUseTransactions, &QCheckBox::toggled, this, &SettingsDatabase::dirtifySettings);
|
||||
connect(m_ui->m_txtMysqlUsername->lineEdit(), &QLineEdit::textChanged, this, &SettingsDatabase::dirtifySettings);
|
||||
connect(m_ui->m_spinMysqlPort, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &SettingsDatabase::dirtifySettings);
|
||||
|
||||
|
@ -133,6 +134,7 @@ void SettingsDatabase::switchMysqlPasswordVisiblity(bool visible) {
|
|||
void SettingsDatabase::loadSettings() {
|
||||
onBeginLoadSettings();
|
||||
|
||||
m_ui->m_checkUseTransactions->setChecked(qApp->settings()->value(GROUP(Database), SETTING(Database::UseTransactions)).toBool());
|
||||
m_ui->m_lblMysqlTestResult->setStatus(WidgetWithStatus::Information, tr("No connection test triggered so far."), tr("You did not executed any connection test yet."));
|
||||
|
||||
// Load SQLite.
|
||||
|
@ -181,6 +183,8 @@ void SettingsDatabase::saveSettings() {
|
|||
const bool original_inmemory = settings()->value(GROUP(Database), SETTING(Database::UseInMemory)).toBool();
|
||||
const bool new_inmemory = m_ui->m_checkSqliteUseInMemoryDatabase->isChecked();
|
||||
|
||||
qApp->settings()->setValue(GROUP(Database), Database::UseTransactions, m_ui->m_checkUseTransactions->isChecked());
|
||||
|
||||
// Save data storage settings.
|
||||
QString original_db_driver = settings()->value(GROUP(Database), SETTING(Database::ActiveDriver)).toString();
|
||||
QString selected_db_driver = m_ui->m_cmbDatabaseDriver->itemData(m_ui->m_cmbDatabaseDriver->currentIndex()).toString();
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>558</width>
|
||||
<height>282</height>
|
||||
<height>356</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
|
@ -36,7 +36,20 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Note that turning this option ON will make saving of new messages FASTER, but it might rarely cause some issues with messages saving.</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignHCenter|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="m_lblDatabaseDriver">
|
||||
<property name="text">
|
||||
<string>Database driver</string>
|
||||
|
@ -46,10 +59,10 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="m_cmbDatabaseDriver"/>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QStackedWidget" name="m_stackedDatabaseDriver">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
|
@ -267,6 +280,13 @@ Authors of this application are NOT responsible for lost data.</string>
|
|||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="m_checkUseTransactions">
|
||||
<property name="text">
|
||||
<string>Use DB transactions when storing downloaded messages</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
|
|
|
@ -450,6 +450,8 @@ int DatabaseQueries::updateMessages(QSqlDatabase db,
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool use_transactions = qApp->settings()->value(GROUP(Database), SETTING(Database::UseTransactions)).toBool();
|
||||
|
||||
// Does not make any difference, since each feed now has
|
||||
// its own "custom ID" (standard feeds have their custom ID equal to primary key ID).
|
||||
int updated_messages = 0;
|
||||
|
@ -488,7 +490,7 @@ int DatabaseQueries::updateMessages(QSqlDatabase db,
|
|||
"SET title = :title, is_read = :is_read, is_important = :is_important, url = :url, author = :author, date_created = :date_created, contents = :contents, enclosures = :enclosures "
|
||||
"WHERE id = :id;");
|
||||
|
||||
if (!query_begin_transaction.exec(qApp->database()->obtainBeginTransactionSql())) {
|
||||
if (use_transactions && !query_begin_transaction.exec(qApp->database()->obtainBeginTransactionSql())) {
|
||||
qCritical("Transaction start for message downloader failed: '%s'.", qPrintable(query_begin_transaction.lastError().text()));
|
||||
return updated_messages;
|
||||
}
|
||||
|
@ -624,7 +626,7 @@ int DatabaseQueries::updateMessages(QSqlDatabase db,
|
|||
qWarning("Failed to set custom ID for all messages: '%s'.", qPrintable(db.lastError().text()));
|
||||
}
|
||||
|
||||
if (!db.commit()) {
|
||||
if (use_transactions && !db.commit()) {
|
||||
qCritical("Transaction commit for message downloader failed: '%s'.", qPrintable(db.lastError().text()));
|
||||
db.rollback();
|
||||
|
||||
|
|
|
@ -216,6 +216,9 @@ DVALUE(int) Proxy::PortDef = 80;
|
|||
// Database.
|
||||
DKEY Database::ID = "database";
|
||||
|
||||
DKEY Database::UseTransactions = "use_transactions";
|
||||
DVALUE(bool) Database::UseTransactionsDef = false;
|
||||
|
||||
DKEY Database::UseInMemory = "use_in_memory_db";
|
||||
DVALUE(bool) Database::UseInMemoryDef = false;
|
||||
|
||||
|
|
|
@ -242,6 +242,9 @@ namespace Proxy {
|
|||
namespace Database {
|
||||
KEY ID;
|
||||
|
||||
KEY UseTransactions;
|
||||
VALUE(bool) UseTransactionsDef;
|
||||
|
||||
KEY UseInMemory;
|
||||
VALUE(bool) UseInMemoryDef;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue