Page MenuHomePhorge

D14742.1768462351.diff
No OneTemporary

Size
3 KB
Referenced Files
None
Subscribers
None

D14742.1768462351.diff

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<SQLiteConnectionManager> connectionManager;
- std::optional<int> getSyncedDatabaseVersion(sqlite3 *db) const;
std::vector<MessageEntity>
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<int>
-SQLiteQueryExecutor::getSyncedDatabaseVersion(sqlite3 *db) const {
- static std::string getDBVersionSyncedMetadataSQL =
- "SELECT * "
- "FROM synced_metadata "
- "WHERE name=\"db_version\";";
- std::vector<SyncedMetadataEntry> entries =
- getAllEntities<SyncedMetadataEntry>(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 <sqlite3.h>
+#include <optional>
#include <string>
namespace comm {
@@ -29,6 +30,7 @@
const std::string &encryptionKey);
static void rekeyDatabase(sqlite3 *db, const std::string &encryptionKey);
static std::vector<std::string> getAllTableNames(sqlite3 *db);
+ static std::optional<int> 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 <sqlite3.h>
#include <fstream>
+#include <optional>
#include <sstream>
#include <string>
#include <vector>
@@ -229,4 +231,17 @@
return tableNames;
}
+std::optional<int> SQLiteUtils::getSyncedDatabaseVersion(sqlite3 *db) {
+ static std::string getDBVersionSyncedMetadataSQL =
+ "SELECT * "
+ "FROM synced_metadata "
+ "WHERE name=\"db_version\";";
+ std::vector<SyncedMetadataEntry> entries =
+ getAllEntities<SyncedMetadataEntry>(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$@<O00001
literal 0
Hc$@<O00001

File Metadata

Mime Type
text/plain
Expires
Thu, Jan 15, 7:32 AM (10 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5932028
Default Alt Text
D14742.1768462351.diff (3 KB)

Event Timeline