Don't sync binlog after creation of SQLite encryption key if it will not be used.

This commit is contained in:
levlam 2024-02-02 15:23:26 +03:00
parent 8377726001
commit 12914669e6

View File

@ -535,8 +535,10 @@ void TdDb::open_impl(Parameters parameters, Promise<OpenedDatabase> &&promise) {
sqlite_key = string(32, ' '); sqlite_key = string(32, ' ');
Random::secure_bytes(sqlite_key); Random::secure_bytes(sqlite_key);
binlog_pmc->set("sqlite_key", sqlite_key); binlog_pmc->set("sqlite_key", sqlite_key);
if (parameters.use_file_database_) {
binlog_pmc->force_sync(Auto(), "TdDb::open_impl 1"); binlog_pmc->force_sync(Auto(), "TdDb::open_impl 1");
} }
}
new_sqlite_key = DbKey::raw_key(std::move(sqlite_key)); new_sqlite_key = DbKey::raw_key(std::move(sqlite_key));
} else { } else {
if (!sqlite_key.empty()) { if (!sqlite_key.empty()) {