Page MenuHomePhorge

D14717.1768404855.diff
No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None

D14717.1768404855.diff

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
@@ -1667,6 +1667,7 @@
throw std::system_error(errno, std::generic_category(), errorStream.str());
}
SQLiteQueryExecutor::generateBackupDataKey();
+ SQLiteQueryExecutor::generateBackupLogDataKey();
SQLiteQueryExecutor::migrate();
}
@@ -1678,17 +1679,21 @@
folly::Optional<std::string> maybeBackupLogDataKey =
CommSecureStore::get(CommSecureStore::backupLogDataKey);
- if (SQLiteUtils::fileExists(databasePath) && maybeBackupDataKey &&
- maybeBackupLogDataKey) {
- SQLiteQueryExecutor::backupDataKey = maybeBackupDataKey.value();
- SQLiteQueryExecutor::backupLogDataKey = maybeBackupLogDataKey.value();
- return;
- } else if (SQLiteUtils::fileExists(databasePath) && maybeBackupDataKey) {
+ // In case of a non-existent database file, we always want to generate fresh
+ // key.
+ if (!SQLiteUtils::fileExists(databasePath) || !maybeBackupDataKey) {
+ SQLiteQueryExecutor::generateBackupDataKey();
+ } else {
SQLiteQueryExecutor::backupDataKey = maybeBackupDataKey.value();
+ }
+
+ // In case of a non-existent database file, we always want to generate fresh
+ // key.
+ if (!SQLiteUtils::fileExists(databasePath) || !maybeBackupLogDataKey) {
SQLiteQueryExecutor::generateBackupLogDataKey();
- return;
+ } else {
+ SQLiteQueryExecutor::backupLogDataKey = maybeBackupLogDataKey.value();
}
- SQLiteQueryExecutor::generateBackupDataKey();
});
}
@@ -1819,7 +1824,6 @@
SQLiteQueryExecutor::backupDataKeySize);
CommSecureStore::set(CommSecureStore::backupDataKey, backupDataKey);
SQLiteQueryExecutor::backupDataKey = backupDataKey;
- SQLiteQueryExecutor::generateBackupLogDataKey();
}
void SQLiteQueryExecutor::generateBackupLogDataKey() {

File Metadata

Mime Type
text/plain
Expires
Wed, Jan 14, 3:34 PM (5 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5929775
Default Alt Text
D14717.1768404855.diff (2 KB)

Event Timeline