diff --git a/src/ui/3rdparty/sqlite/sqlitedb.cpp b/src/ui/3rdparty/sqlite/sqlitedb.cpp index faae340a..ce25a6ba 100644 --- a/src/ui/3rdparty/sqlite/sqlitedb.cpp +++ b/src/ui/3rdparty/sqlite/sqlitedb.cpp @@ -395,7 +395,7 @@ bool SqliteDb::migrateSqlScripts(const MigrateOptions &opt, int userVersion, boo const QDir dir(opt.sqlDir); bool success = true; - beginTransaction(); + beginWriteTransaction(); while (userVersion < opt.version) { ++userVersion; @@ -473,7 +473,7 @@ bool SqliteDb::createFtsTables(const MigrateOptions &opt) bool success = true; - beginTransaction(); + beginWriteTransaction(); for (const FtsTable &ftsTable : opt.ftsTables) { beginSavepoint(); @@ -592,7 +592,7 @@ bool SqliteDb::importDb(const MigrateOptions &opt, const QString &sourceFilePath // Import Data bool success = true; - beginTransaction(); + beginWriteTransaction(); // Copy tables if (opt.autoCopyTables) { diff --git a/src/ui/appinfo/appinfomanager.cpp b/src/ui/appinfo/appinfomanager.cpp index 5e5ff68a..5452ffa5 100644 --- a/src/ui/appinfo/appinfomanager.cpp +++ b/src/ui/appinfo/appinfomanager.cpp @@ -220,7 +220,7 @@ bool AppInfoManager::saveToDb(const QString &appPath, AppInfo &appInfo, const QI bool ok = true; - sqliteDb()->beginTransaction(); + sqliteDb()->beginWriteTransaction(); // Save icon image QVariant iconId; @@ -299,7 +299,7 @@ bool AppInfoManager::deleteAppsAndIcons( { bool ok = false; - sqliteDb()->beginTransaction(); + sqliteDb()->beginWriteTransaction(); // Delete old icons deleteIcons(iconIds, ok); diff --git a/src/ui/conf/confappmanager.cpp b/src/ui/conf/confappmanager.cpp index 2775037d..8eb076f7 100644 --- a/src/ui/conf/confappmanager.cpp +++ b/src/ui/conf/confappmanager.cpp @@ -665,7 +665,7 @@ bool ConfAppManager::updateDriverUpdateAppConf(const App &app) bool ConfAppManager::beginTransaction() { - return sqliteDb()->beginTransaction(); + return sqliteDb()->beginWriteTransaction(); } void ConfAppManager::commitTransaction(bool &ok) diff --git a/src/ui/conf/confmanager.cpp b/src/ui/conf/confmanager.cpp index ef299285..f96d870f 100644 --- a/src/ui/conf/confmanager.cpp +++ b/src/ui/conf/confmanager.cpp @@ -955,7 +955,7 @@ bool ConfManager::saveTask(TaskInfo *taskInfo) bool ConfManager::beginTransaction() { - return sqliteDb()->beginTransaction(); + return sqliteDb()->beginWriteTransaction(); } void ConfManager::commitTransaction(bool &ok) diff --git a/src/ui/conf/confrulemanager.cpp b/src/ui/conf/confrulemanager.cpp index 16881128..23f63cd7 100644 --- a/src/ui/conf/confrulemanager.cpp +++ b/src/ui/conf/confrulemanager.cpp @@ -210,7 +210,7 @@ bool ConfRuleManager::updateDriverRuleFlag(int ruleId, bool enabled) bool ConfRuleManager::beginTransaction() { - return sqliteDb()->beginTransaction(); + return sqliteDb()->beginWriteTransaction(); } void ConfRuleManager::commitTransaction(bool &ok) diff --git a/src/ui/conf/confzonemanager.cpp b/src/ui/conf/confzonemanager.cpp index f123defe..63afa25b 100644 --- a/src/ui/conf/confzonemanager.cpp +++ b/src/ui/conf/confzonemanager.cpp @@ -253,7 +253,7 @@ bool ConfZoneManager::updateDriverZoneFlag(int zoneId, bool enabled) bool ConfZoneManager::beginTransaction() { - return sqliteDb()->beginTransaction(); + return sqliteDb()->beginWriteTransaction(); } void ConfZoneManager::commitTransaction(bool &ok) diff --git a/src/ui/stat/statmanager.cpp b/src/ui/stat/statmanager.cpp index 344793e0..69c8a08c 100644 --- a/src/ui/stat/statmanager.cpp +++ b/src/ui/stat/statmanager.cpp @@ -166,9 +166,14 @@ bool StatManager::updateTrafDay(qint64 unixTime) bool StatManager::clearTraffic() { - sqliteDb()->beginTransaction(); - sqliteDb()->execute(StatSql::sqlDeleteAllTraffic); - sqliteDb()->commitTransaction(); + bool ok = true; + + beginTransaction(); + ok = sqliteDb()->execute(StatSql::sqlDeleteAllTraffic); + commitTransaction(ok); + + if (!ok) + return false; sqliteDb()->vacuum(); // Vacuum outside of transaction @@ -256,7 +261,7 @@ bool StatManager::logStatTraf(const LogEntryStatTraf &entry, qint64 unixTime) const bool isNewDay = updateTrafDay(unixTime); - sqliteDb()->beginTransaction(); + sqliteDb()->beginWriteTransaction(); // Delete old data if (isNewDay) { @@ -328,7 +333,7 @@ bool StatManager::logStatTraf(const LogEntryStatTraf &entry, qint64 unixTime) bool StatManager::deleteStatApp(qint64 appId) { - sqliteDb()->beginTransaction(); + sqliteDb()->beginWriteTransaction(); SqliteStmt::doList({ getIdStmt(StatSql::sqlDeleteAppTrafHour, appId), getIdStmt(StatSql::sqlDeleteAppTrafDay, appId), @@ -599,3 +604,13 @@ SqliteStmt *StatManager::getIdStmt(const char *sql, qint64 id) return stmt; } + +bool StatManager::beginTransaction() +{ + return sqliteDb()->beginWriteTransaction(); +} + +void StatManager::commitTransaction(bool &ok) +{ + ok = sqliteDb()->endTransaction(ok); +} diff --git a/src/ui/stat/statmanager.h b/src/ui/stat/statmanager.h index 3edca7d8..3d18f3fb 100644 --- a/src/ui/stat/statmanager.h +++ b/src/ui/stat/statmanager.h @@ -106,6 +106,9 @@ private: SqliteStmt *getTrafficStmt(const char *sql, qint32 trafTime); SqliteStmt *getIdStmt(const char *sql, qint64 id); + bool beginTransaction(); + void commitTransaction(bool &ok); + private: bool m_isActivePeriodSet : 1 = false; bool m_isActivePeriod : 1 = false;