some cleanups, remove DB transactins support as it is now useless
This commit is contained in:
parent
b0cc456087
commit
ffc9c74900
15 changed files with 73 additions and 121 deletions
|
@ -60,7 +60,7 @@
|
|||
<content_rating type="oars-1.0" />
|
||||
<content_rating type="oars-1.1" />
|
||||
<releases>
|
||||
<release version="4.2.7" date="2023-01-06" />
|
||||
<release version="4.2.7" date="2023-01-09" />
|
||||
</releases>
|
||||
<provides>
|
||||
<binary>@APP_LOW_NAME@</binary>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
DatabaseCleaner::DatabaseCleaner(QObject* parent) : QObject(parent) {}
|
||||
|
||||
void DatabaseCleaner::purgeDatabaseData(CleanerOrders which_data) {
|
||||
qDebugNN << LOGSEC_DB << "Performing database cleanup in thread: '" << QThread::currentThreadId() << "'.";
|
||||
qDebugNN << LOGSEC_DB << "Performing database cleanup in thread:" << QUOTE_W_SPACE_DOT(QThread::currentThreadId());
|
||||
|
||||
// Inform everyone about the start of the process.
|
||||
emit purgeStarted();
|
||||
|
|
|
@ -1086,7 +1086,6 @@ QPair<int, int> DatabaseQueries::updateMessages(QSqlDatabase db,
|
|||
return {0, 0};
|
||||
}
|
||||
|
||||
bool use_transactions = qApp->settings()->value(GROUP(Database), SETTING(Database::UseTransactions)).toBool();
|
||||
QPair<int, int> updated_messages = {0, 0};
|
||||
int account_id = feed->getParentServiceRoot()->accountId();
|
||||
auto feed_custom_id = feed->customId();
|
||||
|
@ -1098,7 +1097,6 @@ QPair<int, int> DatabaseQueries::updateMessages(QSqlDatabase db,
|
|||
QSqlQuery query_select_with_id(db);
|
||||
QSqlQuery query_update(db);
|
||||
QSqlQuery query_insert(db);
|
||||
QSqlQuery query_begin_transaction(db);
|
||||
|
||||
// Here we have query which will check for existence of the "same" message in given feed.
|
||||
// The two message are the "same" if:
|
||||
|
@ -1148,12 +1146,6 @@ QPair<int, int> DatabaseQueries::updateMessages(QSqlDatabase db,
|
|||
"contents = :contents, enclosures = :enclosures, feed = :feed "
|
||||
"WHERE id = :id;"));
|
||||
|
||||
if (use_transactions && !db.transaction()) {
|
||||
qCriticalNN << LOGSEC_DB << "Transaction start for message downloader failed:"
|
||||
<< QUOTE_W_SPACE_DOT(query_begin_transaction.lastError().text());
|
||||
return updated_messages;
|
||||
}
|
||||
|
||||
QVector<Message*> msgs_to_insert;
|
||||
|
||||
for (Message& message : messages) {
|
||||
|
@ -1473,21 +1465,9 @@ QPair<int, int> DatabaseQueries::updateMessages(QSqlDatabase db,
|
|||
qWarningNN << LOGSEC_DB << "Failed to set custom ID for all messages:" << QUOTE_W_SPACE_DOT(db.lastError().text());
|
||||
}
|
||||
|
||||
if (use_transactions && !db.commit()) {
|
||||
qCriticalNN << LOGSEC_DB
|
||||
<< "Transaction commit for message downloader failed:" << QUOTE_W_SPACE_DOT(db.lastError().text());
|
||||
db.rollback();
|
||||
|
||||
if (ok != nullptr) {
|
||||
*ok = false;
|
||||
updated_messages = {0, 0};
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (ok != nullptr) {
|
||||
*ok = true;
|
||||
}
|
||||
}
|
||||
|
||||
return updated_messages;
|
||||
}
|
||||
|
|
|
@ -12,18 +12,14 @@ SettingsDatabase::SettingsDatabase(Settings* settings, QWidget* parent)
|
|||
: SettingsPanel(settings, parent), m_ui(new Ui::SettingsDatabase) {
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_ui->m_lblDataStorageWarning->setHelpText(tr("Note that switching to another data storage type will "
|
||||
"NOT copy existing your data from currently active data "
|
||||
"storage to newly selected one."),
|
||||
true);
|
||||
|
||||
m_ui->m_lblMysqlInfo->setHelpText(tr("Note that speed of used MySQL server and latency of used connection "
|
||||
"medium HEAVILY influences the final performance of this application. "
|
||||
"Using slow database connections leads to bad performance when browsing "
|
||||
"feeds or messages."),
|
||||
false);
|
||||
|
||||
m_ui->m_lblSqliteInMemoryWarnings->setHelpText(tr("Usage of in-memory working database has several advantages "
|
||||
m_ui->m_lblSqliteInMemoryWarnings
|
||||
->setHelpText(tr("Usage of in-memory working database has several advantages "
|
||||
"and pitfalls. Make sure that you are familiar with these "
|
||||
"before you turn this feature on.\n"
|
||||
"\n"
|
||||
|
@ -43,23 +39,43 @@ SettingsDatabase::SettingsDatabase(Settings* settings, QWidget* parent)
|
|||
|
||||
m_ui->m_txtMysqlPassword->lineEdit()->setPasswordMode(true);
|
||||
|
||||
connect(m_ui->m_cmbDatabaseDriver, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||
connect(m_ui->m_cmbDatabaseDriver,
|
||||
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||
this,
|
||||
&SettingsDatabase::dirtifySettings);
|
||||
connect(m_ui->m_checkSqliteUseInMemoryDatabase, &QCheckBox::toggled, 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_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);
|
||||
connect(m_ui->m_cmbDatabaseDriver, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||
connect(m_ui->m_spinMysqlPort,
|
||||
static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
|
||||
this,
|
||||
&SettingsDatabase::dirtifySettings);
|
||||
connect(m_ui->m_cmbDatabaseDriver,
|
||||
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||
this,
|
||||
&SettingsDatabase::selectSqlBackend);
|
||||
connect(m_ui->m_txtMysqlUsername->lineEdit(), &BaseLineEdit::textChanged, this, &SettingsDatabase::onMysqlUsernameChanged);
|
||||
connect(m_ui->m_txtMysqlHostname->lineEdit(), &BaseLineEdit::textChanged, this, &SettingsDatabase::onMysqlHostnameChanged);
|
||||
connect(m_ui->m_txtMysqlPassword->lineEdit(), &BaseLineEdit::textChanged, this, &SettingsDatabase::onMysqlPasswordChanged);
|
||||
connect(m_ui->m_txtMysqlDatabase->lineEdit(), &BaseLineEdit::textChanged, this, &SettingsDatabase::onMysqlDatabaseChanged);
|
||||
connect(m_ui->m_txtMysqlUsername->lineEdit(),
|
||||
&BaseLineEdit::textChanged,
|
||||
this,
|
||||
&SettingsDatabase::onMysqlUsernameChanged);
|
||||
connect(m_ui->m_txtMysqlHostname->lineEdit(),
|
||||
&BaseLineEdit::textChanged,
|
||||
this,
|
||||
&SettingsDatabase::onMysqlHostnameChanged);
|
||||
connect(m_ui->m_txtMysqlPassword->lineEdit(),
|
||||
&BaseLineEdit::textChanged,
|
||||
this,
|
||||
&SettingsDatabase::onMysqlPasswordChanged);
|
||||
connect(m_ui->m_txtMysqlDatabase->lineEdit(),
|
||||
&BaseLineEdit::textChanged,
|
||||
this,
|
||||
&SettingsDatabase::onMysqlDatabaseChanged);
|
||||
connect(m_ui->m_btnMysqlTestSetup, &QPushButton::clicked, this, &SettingsDatabase::mysqlTestConnection);
|
||||
connect(m_ui->m_cmbDatabaseDriver, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||
connect(m_ui->m_cmbDatabaseDriver,
|
||||
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||
this,
|
||||
&SettingsDatabase::requireRestart);
|
||||
connect(m_ui->m_checkSqliteUseInMemoryDatabase, &QCheckBox::toggled, this, &SettingsDatabase::requireRestart);
|
||||
connect(m_ui->m_spinMysqlPort, &QSpinBox::editingFinished, this, &SettingsDatabase::requireRestart);
|
||||
|
@ -139,17 +155,14 @@ void SettingsDatabase::selectSqlBackend(int index) {
|
|||
m_ui->m_stackedDatabaseDriver->setCurrentIndex(1);
|
||||
}
|
||||
else {
|
||||
qWarningNN << LOGSEC_GUI
|
||||
<< "GUI for given database driver '"
|
||||
<< selected_db_driver
|
||||
<< "' is not available.";
|
||||
qWarningNN << LOGSEC_GUI << "GUI for given database driver '" << selected_db_driver << "' is not available.";
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsDatabase::loadSettings() {
|
||||
onBeginLoadSettings();
|
||||
m_ui->m_checkUseTransactions->setChecked(qApp->settings()->value(GROUP(Database), SETTING(Database::UseTransactions)).toBool());
|
||||
m_ui->m_lblMysqlTestResult->setStatus(WidgetWithStatus::StatusType::Information, tr("No connection test triggered so far."),
|
||||
m_ui->m_lblMysqlTestResult->setStatus(WidgetWithStatus::StatusType::Information,
|
||||
tr("No connection test triggered so far."),
|
||||
tr("You did not executed any connection test yet."));
|
||||
|
||||
// Load SQLite.
|
||||
|
@ -158,7 +171,8 @@ void SettingsDatabase::loadSettings() {
|
|||
m_ui->m_cmbDatabaseDriver->addItem(lite_driver->humanDriverType(), lite_driver->qtDriverCode());
|
||||
|
||||
// Load in-memory database status.
|
||||
m_ui->m_checkSqliteUseInMemoryDatabase->setChecked(settings()->value(GROUP(Database), SETTING(Database::UseInMemory)).toBool());
|
||||
m_ui->m_checkSqliteUseInMemoryDatabase
|
||||
->setChecked(settings()->value(GROUP(Database), SETTING(Database::UseInMemory)).toBool());
|
||||
|
||||
auto* mysq_driver = qApp->database()->driverForType(DatabaseDriver::DriverType::MySQL);
|
||||
|
||||
|
@ -176,16 +190,19 @@ void SettingsDatabase::loadSettings() {
|
|||
m_ui->m_txtMysqlUsername->lineEdit()->setPlaceholderText(tr("Username to login with"));
|
||||
m_ui->m_txtMysqlPassword->lineEdit()->setPlaceholderText(tr("Password for your username"));
|
||||
m_ui->m_txtMysqlDatabase->lineEdit()->setPlaceholderText(tr("Working database which you have full access to."));
|
||||
m_ui->m_txtMysqlHostname->lineEdit()->setText(settings()->value(GROUP(Database), SETTING(Database::MySQLHostname)).toString());
|
||||
m_ui->m_txtMysqlUsername->lineEdit()->setText(settings()->value(GROUP(Database), SETTING(Database::MySQLUsername)).toString());
|
||||
m_ui->m_txtMysqlPassword->lineEdit()->setText(settings()->password(GROUP(Database),
|
||||
SETTING(Database::MySQLPassword)).toString());
|
||||
m_ui->m_txtMysqlDatabase->lineEdit()->setText(settings()->value(GROUP(Database), SETTING(Database::MySQLDatabase)).toString());
|
||||
m_ui->m_txtMysqlHostname->lineEdit()
|
||||
->setText(settings()->value(GROUP(Database), SETTING(Database::MySQLHostname)).toString());
|
||||
m_ui->m_txtMysqlUsername->lineEdit()
|
||||
->setText(settings()->value(GROUP(Database), SETTING(Database::MySQLUsername)).toString());
|
||||
m_ui->m_txtMysqlPassword->lineEdit()
|
||||
->setText(settings()->password(GROUP(Database), SETTING(Database::MySQLPassword)).toString());
|
||||
m_ui->m_txtMysqlDatabase->lineEdit()
|
||||
->setText(settings()->value(GROUP(Database), SETTING(Database::MySQLDatabase)).toString());
|
||||
m_ui->m_spinMysqlPort->setValue(settings()->value(GROUP(Database), SETTING(Database::MySQLPort)).toInt());
|
||||
}
|
||||
|
||||
int index_current_backend = m_ui->m_cmbDatabaseDriver->findData(settings()->value(GROUP(Database),
|
||||
SETTING(Database::ActiveDriver)).toString());
|
||||
int index_current_backend =
|
||||
m_ui->m_cmbDatabaseDriver->findData(settings()->value(GROUP(Database), SETTING(Database::ActiveDriver)).toString());
|
||||
|
||||
if (index_current_backend >= 0) {
|
||||
m_ui->m_cmbDatabaseDriver->setCurrentIndex(index_current_backend);
|
||||
|
@ -201,11 +218,10 @@ 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();
|
||||
QString selected_db_driver =
|
||||
m_ui->m_cmbDatabaseDriver->itemData(m_ui->m_cmbDatabaseDriver->currentIndex()).toString();
|
||||
|
||||
// Save SQLite.
|
||||
settings()->setValue(GROUP(Database), Database::UseInMemory, new_inmemory);
|
||||
|
|
|
@ -11,20 +11,7 @@
|
|||
</rect>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="m_checkUseTransactions">
|
||||
<property name="toolTip">
|
||||
<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="text">
|
||||
<string>Use DB transactions when storing downloaded messages</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="HelpSpoiler" name="m_lblDataStorageWarning" native="true"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="m_lblDatabaseDriver">
|
||||
<property name="text">
|
||||
<string>Database driver</string>
|
||||
|
@ -34,10 +21,10 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="m_cmbDatabaseDriver"/>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QStackedWidget" name="m_stackedDatabaseDriver">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
|
@ -204,7 +191,7 @@
|
|||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<item row="2" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
|
@ -218,11 +205,6 @@
|
|||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
<zorder>m_lblDatabaseDriver</zorder>
|
||||
<zorder>m_cmbDatabaseDriver</zorder>
|
||||
<zorder>m_stackedDatabaseDriver</zorder>
|
||||
<zorder>m_checkUseTransactions</zorder>
|
||||
<zorder>m_lblDataStorageWarning</zorder>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
|
|
@ -374,9 +374,6 @@ 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;
|
||||
|
||||
|
|
|
@ -401,9 +401,6 @@ namespace Proxy {
|
|||
// Database.
|
||||
namespace Database {
|
||||
KEY ID;
|
||||
KEY UseTransactions;
|
||||
|
||||
VALUE(bool) UseTransactionsDef;
|
||||
|
||||
KEY UseInMemory;
|
||||
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
#include "services/abstract/serviceroot.h"
|
||||
#include "services/abstract/unreadnode.h"
|
||||
|
||||
#include <QThread>
|
||||
|
||||
Feed::Feed(RootItem* parent)
|
||||
: RootItem(parent), m_source(QString()), m_status(Status::Normal), m_statusString(QString()),
|
||||
m_autoUpdateType(AutoUpdateType::DefaultAutoUpdate), m_autoUpdateInterval(DEFAULT_AUTO_UPDATE_INTERVAL),
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
#include "services/abstract/cacheforserviceroot.h"
|
||||
#include "services/abstract/serviceroot.h"
|
||||
|
||||
#include <QThread>
|
||||
|
||||
ImportantNode::ImportantNode(RootItem* parent_item) : RootItem(parent_item) {
|
||||
setKind(RootItem::Kind::Important);
|
||||
setId(ID_IMPORTANT);
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
#include <QThread>
|
||||
|
||||
Label::Label(const QString& name, const QColor& color, RootItem* parent_item) : Label(parent_item) {
|
||||
setColor(color);
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
#include "services/abstract/cacheforserviceroot.h"
|
||||
#include "services/abstract/serviceroot.h"
|
||||
|
||||
#include <QThread>
|
||||
|
||||
RecycleBin::RecycleBin(RootItem* parent_item) : RootItem(parent_item), m_totalCount(0), m_unreadCount(0) {
|
||||
setKind(RootItem::Kind::Bin);
|
||||
setId(ID_RECYCLE_BIN);
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
#include "services/abstract/recyclebin.h"
|
||||
#include "services/abstract/unreadnode.h"
|
||||
|
||||
#include <QThread>
|
||||
|
||||
ServiceRoot::ServiceRoot(RootItem* parent)
|
||||
: RootItem(parent), m_recycleBin(new RecycleBin(this)), m_importantNode(new ImportantNode(this)),
|
||||
m_labelsNode(new LabelsNode(this)), m_unreadNode(new UnreadNode(this)), m_accountId(NO_PARENT_CATEGORY),
|
||||
|
@ -953,7 +951,6 @@ QPair<int, int> ServiceRoot::updateMessages(QList<Message>& messages, Feed* feed
|
|||
return updated_messages;
|
||||
}
|
||||
|
||||
QList<RootItem*> items_to_update;
|
||||
bool ok = false;
|
||||
QSqlDatabase database = qApp->database()->driver()->threadSafeConnection(metaObject()->className());
|
||||
|
||||
|
@ -967,28 +964,22 @@ QPair<int, int> ServiceRoot::updateMessages(QList<Message>& messages, Feed* feed
|
|||
|
||||
if (recycleBin() != nullptr) {
|
||||
recycleBin()->updateCounts(true);
|
||||
items_to_update.append(recycleBin());
|
||||
}
|
||||
|
||||
if (importantNode() != nullptr) {
|
||||
importantNode()->updateCounts(true);
|
||||
items_to_update.append(importantNode());
|
||||
}
|
||||
|
||||
if (unreadNode() != nullptr) {
|
||||
unreadNode()->updateCounts(true);
|
||||
items_to_update.append(unreadNode());
|
||||
}
|
||||
|
||||
if (labelsNode() != nullptr) {
|
||||
labelsNode()->updateCounts(true);
|
||||
items_to_update.append(labelsNode());
|
||||
}
|
||||
}
|
||||
|
||||
// Some messages were really added to DB, reload feed in model.
|
||||
items_to_update.append(feed);
|
||||
// getParentServiceRoot()->itemChanged(items_to_update);
|
||||
// NOTE: Do not update model items here. We update only once when all feeds are fetched.
|
||||
|
||||
return updated_messages;
|
||||
}
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
#include "miscellaneous/application.h"
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
|
||||
#include <QThread>
|
||||
|
||||
UnreadNode::UnreadNode(RootItem* parent_item) : RootItem(parent_item) {
|
||||
setKind(RootItem::Kind::Unread);
|
||||
setId(ID_UNREAD);
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QRegularExpression>
|
||||
#include <QThread>
|
||||
#include <QUrl>
|
||||
|
||||
GmailNetworkFactory::GmailNetworkFactory(QObject* parent)
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QRegularExpression>
|
||||
#include <QThread>
|
||||
#include <QUrl>
|
||||
|
||||
RedditNetworkFactory::RedditNetworkFactory(QObject* parent)
|
||||
|
|
Loading…
Add table
Reference in a new issue