diff --git a/src/ui/3rdparty/sqlite/sqlitedb.cpp b/src/ui/3rdparty/sqlite/sqlitedb.cpp index e0268934..d3692bc3 100644 --- a/src/ui/3rdparty/sqlite/sqlitedb.cpp +++ b/src/ui/3rdparty/sqlite/sqlitedb.cpp @@ -14,6 +14,8 @@ namespace { const QLoggingCategory LC("db"); +constexpr int DATABASE_BUSY_TIMEOUT = 2000; // 2 seconds + const char *const defaultSqlPragmas = "PRAGMA journal_mode = WAL;" "PRAGMA locking_mode = NORMAL;" "PRAGMA synchronous = NORMAL;" @@ -333,6 +335,8 @@ QStringList SqliteDb::columnNames(const QString &tableName, const QString &schem bool SqliteDb::migrate(MigrateOptions &opt) { + setBusyTimeoutMs(DATABASE_BUSY_TIMEOUT); + if (!opt.sqlPragmas) { opt.sqlPragmas = defaultSqlPragmas; } diff --git a/src/ui/stat/statblockmanager.cpp b/src/ui/stat/statblockmanager.cpp index 07ac3493..076ea663 100644 --- a/src/ui/stat/statblockmanager.cpp +++ b/src/ui/stat/statblockmanager.cpp @@ -20,8 +20,6 @@ const QLoggingCategory LC("statBlock"); constexpr int DATABASE_USER_VERSION = 7; -constexpr int DATABASE_BUSY_TIMEOUT = 3000; // 3 seconds - bool migrateFunc(SqliteDb *db, int version, bool isNewDb, void *ctx) { Q_UNUSED(ctx); @@ -191,12 +189,8 @@ bool StatBlockManager::setupDb() << roSqliteDb()->errorMessage(); return false; } - - roSqliteDb()->setBusyTimeoutMs(DATABASE_BUSY_TIMEOUT); } - sqliteDb()->setBusyTimeoutMs(DATABASE_BUSY_TIMEOUT); - return true; }