diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h --- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h +++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h @@ -25,7 +25,6 @@ sqlite3 *getConnection() const; std::shared_ptr connectionManager; - std::optional getSyncedDatabaseVersion(sqlite3 *db) const; std::vector processMessagesResults(SQLiteStatementWrapper &preparedSQL) const; std::string getThickThreadTypesList() const; diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp --- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp +++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp @@ -796,20 +796,6 @@ this->getConnection(), getAllSyncedMetadataSQL); } -std::optional -SQLiteQueryExecutor::getSyncedDatabaseVersion(sqlite3 *db) const { - static std::string getDBVersionSyncedMetadataSQL = - "SELECT * " - "FROM synced_metadata " - "WHERE name=\"db_version\";"; - std::vector entries = - getAllEntities(db, getDBVersionSyncedMetadataSQL); - for (auto &entry : entries) { - return std::stoi(entry.data); - } - return std::nullopt; -} - void SQLiteQueryExecutor::replaceAuxUserInfo( const AuxUserInfo &userInfo) const { static std::string replaceAuxUserInfoSQL = @@ -1559,7 +1545,7 @@ sqlite3_open(plaintextBackupPath.c_str(), &backupDB); - int version = this->getSyncedDatabaseVersion(backupDB).value_or(-1); + int version = SQLiteUtils::getSyncedDatabaseVersion(backupDB).value_or(-1); if (version > std::stoi(maxVersion)) { std::stringstream error_message; error_message << "Failed to restore a backup because it was created " diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteUtils.h b/native/cpp/CommonCpp/DatabaseManagers/SQLiteUtils.h --- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteUtils.h +++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteUtils.h @@ -2,6 +2,7 @@ #include +#include #include namespace comm { @@ -29,6 +30,7 @@ const std::string &encryptionKey); static void rekeyDatabase(sqlite3 *db, const std::string &encryptionKey); static std::vector getAllTableNames(sqlite3 *db); + static std::optional getSyncedDatabaseVersion(sqlite3 *db); }; } // namespace comm diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteUtils.cpp b/native/cpp/CommonCpp/DatabaseManagers/SQLiteUtils.cpp --- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteUtils.cpp +++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteUtils.cpp @@ -2,9 +2,11 @@ #include "Logger.h" #include "entities/EntityQueryHelpers.h" +#include "entities/SyncedMetadataEntry.h" #include #include +#include #include #include #include @@ -229,4 +231,17 @@ return tableNames; } +std::optional SQLiteUtils::getSyncedDatabaseVersion(sqlite3 *db) { + static std::string getDBVersionSyncedMetadataSQL = + "SELECT * " + "FROM synced_metadata " + "WHERE name=\"db_version\";"; + std::vector entries = + getAllEntities(db, getDBVersionSyncedMetadataSQL); + for (auto &entry : entries) { + return std::stoi(entry.data); + } + return std::nullopt; +} + } // namespace comm diff --git a/web/shared-worker/_generated/comm_query_executor.wasm b/web/shared-worker/_generated/comm_query_executor.wasm index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 GIT binary patch literal 0 Hc$@