This commit is contained in:
Martin Rotter 2017-01-13 09:28:09 +01:00
parent ce57ed6d9a
commit 211494a1d8
6 changed files with 39 additions and 6 deletions

View file

@ -2,6 +2,7 @@
————— —————
Added: 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) ▪ 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) ▪ 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. ▪ 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.

View file

@ -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_txtMysqlDatabase->lineEdit(), &QLineEdit::textChanged, this, &SettingsDatabase::dirtifySettings);
connect(m_ui->m_txtMysqlHostname->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_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_txtMysqlUsername->lineEdit(), &QLineEdit::textChanged, this, &SettingsDatabase::dirtifySettings);
connect(m_ui->m_spinMysqlPort, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), 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() { void SettingsDatabase::loadSettings() {
onBeginLoadSettings(); 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.")); 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. // Load SQLite.
@ -181,6 +183,8 @@ void SettingsDatabase::saveSettings() {
const bool original_inmemory = settings()->value(GROUP(Database), SETTING(Database::UseInMemory)).toBool(); const bool original_inmemory = settings()->value(GROUP(Database), SETTING(Database::UseInMemory)).toBool();
const bool new_inmemory = m_ui->m_checkSqliteUseInMemoryDatabase->isChecked(); 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. // Save data storage settings.
QString original_db_driver = settings()->value(GROUP(Database), SETTING(Database::ActiveDriver)).toString(); 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(); QString selected_db_driver = m_ui->m_cmbDatabaseDriver->itemData(m_ui->m_cmbDatabaseDriver->currentIndex()).toString();

View file

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>558</width> <width>558</width>
<height>282</height> <height>356</height>
</rect> </rect>
</property> </property>
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
@ -36,7 +36,20 @@
</property> </property>
</widget> </widget>
</item> </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"> <widget class="QLabel" name="m_lblDatabaseDriver">
<property name="text"> <property name="text">
<string>Database driver</string> <string>Database driver</string>
@ -46,10 +59,10 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="3" column="1">
<widget class="QComboBox" name="m_cmbDatabaseDriver"/> <widget class="QComboBox" name="m_cmbDatabaseDriver"/>
</item> </item>
<item row="2" column="0" colspan="2"> <item row="4" column="0" colspan="2">
<widget class="QStackedWidget" name="m_stackedDatabaseDriver"> <widget class="QStackedWidget" name="m_stackedDatabaseDriver">
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>1</number>
@ -267,6 +280,13 @@ Authors of this application are NOT responsible for lost data.</string>
</widget> </widget>
</widget> </widget>
</item> </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> </layout>
</widget> </widget>
<customwidgets> <customwidgets>

View file

@ -450,6 +450,8 @@ int DatabaseQueries::updateMessages(QSqlDatabase db,
return 0; return 0;
} }
bool use_transactions = qApp->settings()->value(GROUP(Database), SETTING(Database::UseTransactions)).toBool();
// Does not make any difference, since each feed now has // 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). // its own "custom ID" (standard feeds have their custom ID equal to primary key ID).
int updated_messages = 0; 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 " "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;"); "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())); qCritical("Transaction start for message downloader failed: '%s'.", qPrintable(query_begin_transaction.lastError().text()));
return updated_messages; 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())); 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())); qCritical("Transaction commit for message downloader failed: '%s'.", qPrintable(db.lastError().text()));
db.rollback(); db.rollback();

View file

@ -216,6 +216,9 @@ DVALUE(int) Proxy::PortDef = 80;
// Database. // Database.
DKEY Database::ID = "database"; DKEY Database::ID = "database";
DKEY Database::UseTransactions = "use_transactions";
DVALUE(bool) Database::UseTransactionsDef = false;
DKEY Database::UseInMemory = "use_in_memory_db"; DKEY Database::UseInMemory = "use_in_memory_db";
DVALUE(bool) Database::UseInMemoryDef = false; DVALUE(bool) Database::UseInMemoryDef = false;

View file

@ -242,6 +242,9 @@ namespace Proxy {
namespace Database { namespace Database {
KEY ID; KEY ID;
KEY UseTransactions;
VALUE(bool) UseTransactionsDef;
KEY UseInMemory; KEY UseInMemory;
VALUE(bool) UseInMemoryDef; VALUE(bool) UseInMemoryDef;