Make TdParameters private in Global.

This commit is contained in:
levlam 2023-03-13 19:47:38 +03:00
parent 68336dbefc
commit 835ee52491
22 changed files with 276 additions and 268 deletions

View File

@ -546,7 +546,7 @@ void AnimationsManager::load_saved_animations(Promise<Unit> &&promise) {
} }
load_saved_animations_queries_.push_back(std::move(promise)); load_saved_animations_queries_.push_back(std::move(promise));
if (load_saved_animations_queries_.size() == 1u) { if (load_saved_animations_queries_.size() == 1u) {
if (G()->parameters().use_file_db) { // otherwise there is no sqlite_pmc, TODO if (G()->use_file_database()) { // otherwise there is no sqlite_pmc, TODO
LOG(INFO) << "Trying to load saved animations from database"; LOG(INFO) << "Trying to load saved animations from database";
G()->td_db()->get_sqlite_pmc()->get("ans", PromiseCreator::lambda([](string value) { G()->td_db()->get_sqlite_pmc()->get("ans", PromiseCreator::lambda([](string value) {
send_closure(G()->animations_manager(), send_closure(G()->animations_manager(),
@ -856,7 +856,7 @@ void AnimationsManager::send_update_saved_animations(bool from_database) {
} }
void AnimationsManager::save_saved_animations_to_database() { void AnimationsManager::save_saved_animations_to_database() {
if (G()->parameters().use_file_db) { if (G()->use_file_database()) {
LOG(INFO) << "Save saved animations to database"; LOG(INFO) << "Save saved animations to database";
AnimationListLogEvent log_event(saved_animation_ids_); AnimationListLogEvent log_event(saved_animation_ids_);
G()->td_db()->get_sqlite_pmc()->set("ans", log_event_store(log_event).as_slice().str(), Auto()); G()->td_db()->get_sqlite_pmc()->set("ans", log_event_store(log_event).as_slice().str(), Auto());

View File

@ -571,7 +571,7 @@ void AttachMenuManager::init() {
} }
is_inited_ = true; is_inited_ = true;
if (!G()->parameters().use_chat_info_db) { if (!G()->use_chat_info_database()) {
G()->td_db()->get_binlog_pmc()->erase(get_attach_menu_bots_database_key()); G()->td_db()->get_binlog_pmc()->erase(get_attach_menu_bots_database_key());
} else { } else {
auto attach_menu_bots_string = G()->td_db()->get_binlog_pmc()->get(get_attach_menu_bots_database_key()); auto attach_menu_bots_string = G()->td_db()->get_binlog_pmc()->get(get_attach_menu_bots_database_key());
@ -1247,7 +1247,7 @@ string AttachMenuManager::get_attach_menu_bots_database_key() {
} }
void AttachMenuManager::save_attach_menu_bots() { void AttachMenuManager::save_attach_menu_bots() {
if (!G()->parameters().use_chat_info_db) { if (!G()->use_chat_info_database()) {
return; return;
} }

View File

@ -284,7 +284,7 @@ void AutosaveManager::load_autosave_settings(Promise<td_api::object_ptr<td_api::
return; return;
} }
if (G()->parameters().use_message_db) { if (G()->use_message_database()) {
G()->td_db()->get_sqlite_pmc()->get( G()->td_db()->get_sqlite_pmc()->get(
get_autosave_settings_database_key(), PromiseCreator::lambda([actor_id = actor_id(this)](string value) mutable { get_autosave_settings_database_key(), PromiseCreator::lambda([actor_id = actor_id(this)](string value) mutable {
send_closure(actor_id, &AutosaveManager::on_load_autosave_settings_from_database, std::move(value)); send_closure(actor_id, &AutosaveManager::on_load_autosave_settings_from_database, std::move(value));
@ -436,7 +436,7 @@ void AutosaveManager::on_get_autosave_settings(
} }
void AutosaveManager::save_autosave_settings() { void AutosaveManager::save_autosave_settings() {
if (G()->parameters().use_message_db) { if (G()->use_message_database()) {
LOG(INFO) << "Save autosave settings to database"; LOG(INFO) << "Save autosave settings to database";
G()->td_db()->get_sqlite_pmc()->set(get_autosave_settings_database_key(), G()->td_db()->get_sqlite_pmc()->set(get_autosave_settings_database_key(),
log_event_store(settings_).as_slice().str(), Auto()); log_event_store(settings_).as_slice().str(), Auto());

View File

@ -495,7 +495,7 @@ std::pair<BackgroundId, BackgroundType> BackgroundManager::search_background(con
return {background_id, r_type.ok()}; return {background_id, r_type.ok()};
} }
if (G()->parameters().use_file_db && loaded_from_database_backgrounds_.count(slug) == 0) { if (G()->use_file_database() && loaded_from_database_backgrounds_.count(slug) == 0) {
auto &queries = being_loaded_from_database_backgrounds_[slug]; auto &queries = being_loaded_from_database_backgrounds_[slug];
queries.push_back(std::move(promise)); queries.push_back(std::move(promise));
if (queries.size() == 1) { if (queries.size() == 1) {
@ -1119,7 +1119,7 @@ std::pair<BackgroundId, BackgroundType> BackgroundManager::on_get_background(
name_to_background_id_.emplace(expected_background_name, background_id); name_to_background_id_.emplace(expected_background_name, background_id);
} }
if (G()->parameters().use_file_db) { if (G()->use_file_database()) {
LOG(INFO) << "Save " << background_id << " to database with name " << background.name; LOG(INFO) << "Save " << background_id << " to database with name " << background.name;
CHECK(!BackgroundType::is_background_name_local(background.name)); CHECK(!BackgroundType::is_background_name_local(background.name));
G()->td_db()->get_sqlite_pmc()->set(get_background_name_database_key(background.name), G()->td_db()->get_sqlite_pmc()->set(get_background_name_database_key(background.name),

View File

@ -3941,7 +3941,7 @@ ContactsManager::ContactsManager(Td *td, ActorShared<> parent) : td_(td), parent
td_->option_manager_->set_option_integer("anti_spam_bot_user_id", get_anti_spam_bot_user_id().get()); td_->option_manager_->set_option_integer("anti_spam_bot_user_id", get_anti_spam_bot_user_id().get());
} }
if (G()->parameters().use_chat_info_db) { if (G()->use_chat_info_database()) {
auto next_contacts_sync_date_string = G()->td_db()->get_binlog_pmc()->get("next_contacts_sync_date"); auto next_contacts_sync_date_string = G()->td_db()->get_binlog_pmc()->get("next_contacts_sync_date");
if (!next_contacts_sync_date_string.empty()) { if (!next_contacts_sync_date_string.empty()) {
next_contacts_sync_date_ = min(to_integer<int32>(next_contacts_sync_date_string), G()->unix_time() + 100000); next_contacts_sync_date_ = min(to_integer<int32>(next_contacts_sync_date_string), G()->unix_time() + 100000);
@ -3955,7 +3955,7 @@ ContactsManager::ContactsManager(Td *td, ActorShared<> parent) : td_(td), parent
G()->td_db()->get_binlog_pmc()->erase("next_contacts_sync_date"); G()->td_db()->get_binlog_pmc()->erase("next_contacts_sync_date");
G()->td_db()->get_binlog_pmc()->erase("saved_contact_count"); G()->td_db()->get_binlog_pmc()->erase("saved_contact_count");
} }
if (G()->parameters().use_file_db) { if (G()->use_file_database()) {
G()->td_db()->get_sqlite_pmc()->erase_by_prefix("us_bot_info", Auto()); G()->td_db()->get_sqlite_pmc()->erase_by_prefix("us_bot_info", Auto());
} }
@ -6116,7 +6116,7 @@ void ContactsManager::load_contacts(Promise<Unit> &&promise) {
} }
load_contacts_queries_.push_back(std::move(promise)); load_contacts_queries_.push_back(std::move(promise));
if (load_contacts_queries_.size() == 1u) { if (load_contacts_queries_.size() == 1u) {
if (G()->parameters().use_chat_info_db && next_contacts_sync_date_ > 0 && saved_contact_count_ != -1) { if (G()->use_chat_info_database() && next_contacts_sync_date_ > 0 && saved_contact_count_ != -1) {
LOG(INFO) << "Load contacts from database"; LOG(INFO) << "Load contacts from database";
G()->td_db()->get_sqlite_pmc()->get( G()->td_db()->get_sqlite_pmc()->get(
"user_contacts", PromiseCreator::lambda([](string value) { "user_contacts", PromiseCreator::lambda([](string value) {
@ -6363,7 +6363,7 @@ void ContactsManager::load_imported_contacts(Promise<Unit> &&promise) {
} }
load_imported_contacts_queries_.push_back(std::move(promise)); load_imported_contacts_queries_.push_back(std::move(promise));
if (load_imported_contacts_queries_.size() == 1u) { if (load_imported_contacts_queries_.size() == 1u) {
if (G()->parameters().use_chat_info_db) { if (G()->use_chat_info_database()) {
LOG(INFO) << "Load imported contacts from database"; LOG(INFO) << "Load imported contacts from database";
G()->td_db()->get_sqlite_pmc()->get( G()->td_db()->get_sqlite_pmc()->get(
"user_imported_contacts", PromiseCreator::lambda([](string value) { "user_imported_contacts", PromiseCreator::lambda([](string value) {
@ -6453,7 +6453,7 @@ std::pair<vector<UserId>, vector<int32>> ContactsManager::change_imported_contac
if (need_clear_imported_contacts_) { if (need_clear_imported_contacts_) {
need_clear_imported_contacts_ = false; need_clear_imported_contacts_ = false;
all_imported_contacts_.clear(); all_imported_contacts_.clear();
if (G()->parameters().use_chat_info_db) { if (G()->use_chat_info_database()) {
G()->td_db()->get_sqlite_pmc()->erase("user_imported_contacts", Auto()); G()->td_db()->get_sqlite_pmc()->erase("user_imported_contacts", Auto());
} }
reload_contacts(true); reload_contacts(true);
@ -6592,7 +6592,7 @@ void ContactsManager::on_update_contacts_reset() {
*/ */
saved_contact_count_ = 0; saved_contact_count_ = 0;
if (G()->parameters().use_chat_info_db) { if (G()->use_chat_info_database()) {
G()->td_db()->get_binlog_pmc()->set("saved_contact_count", "0"); G()->td_db()->get_binlog_pmc()->set("saved_contact_count", "0");
G()->td_db()->get_sqlite_pmc()->erase("user_imported_contacts", Auto()); G()->td_db()->get_sqlite_pmc()->erase("user_imported_contacts", Auto());
} }
@ -9178,7 +9178,7 @@ void ContactsManager::get_created_public_dialogs(PublicDialogType type,
return return_created_public_dialogs(std::move(promise), created_public_channels_[index]); return return_created_public_dialogs(std::move(promise), created_public_channels_[index]);
} }
if (get_created_public_channels_queries_[index].empty() && G()->parameters().use_chat_info_db) { if (get_created_public_channels_queries_[index].empty() && G()->use_chat_info_database()) {
auto pmc_key = PSTRING() << "public_channels" << index; auto pmc_key = PSTRING() << "public_channels" << index;
auto str = G()->td_db()->get_binlog_pmc()->get(pmc_key); auto str = G()->td_db()->get_binlog_pmc()->get(pmc_key);
if (!str.empty()) { if (!str.empty()) {
@ -9314,7 +9314,7 @@ void ContactsManager::on_get_created_public_channels(PublicDialogType type,
void ContactsManager::save_created_public_channels(PublicDialogType type) { void ContactsManager::save_created_public_channels(PublicDialogType type) {
auto index = static_cast<int32>(type); auto index = static_cast<int32>(type);
CHECK(created_public_channels_inited_[index]); CHECK(created_public_channels_inited_[index]);
if (G()->parameters().use_chat_info_db) { if (G()->use_chat_info_database()) {
G()->td_db()->get_binlog_pmc()->set( G()->td_db()->get_binlog_pmc()->set(
PSTRING() << "public_channels" << index, PSTRING() << "public_channels" << index,
implode( implode(
@ -9500,7 +9500,7 @@ void ContactsManager::on_import_contacts_finished(int64 random_id, vector<UserId
unique_id_to_unimported_contact_invites[narrow_cast<int64>(unique_id)] = unimported_contact_invites[i]; unique_id_to_unimported_contact_invites[narrow_cast<int64>(unique_id)] = unimported_contact_invites[i];
} }
if (G()->parameters().use_chat_info_db) { if (G()->use_chat_info_database()) {
G()->td_db()->get_binlog()->force_sync(PromiseCreator::lambda( G()->td_db()->get_binlog()->force_sync(PromiseCreator::lambda(
[log_event = log_event_store(all_imported_contacts_).as_slice().str()](Result<> result) mutable { [log_event = log_event_store(all_imported_contacts_).as_slice().str()](Result<> result) mutable {
if (result.is_ok()) { if (result.is_ok()) {
@ -9556,7 +9556,7 @@ void ContactsManager::save_next_contacts_sync_date() {
if (G()->close_flag()) { if (G()->close_flag()) {
return; return;
} }
if (!G()->parameters().use_chat_info_db) { if (!G()->use_chat_info_database()) {
return; return;
} }
G()->td_db()->get_binlog_pmc()->set("next_contacts_sync_date", to_string(next_contacts_sync_date_)); G()->td_db()->get_binlog_pmc()->set("next_contacts_sync_date", to_string(next_contacts_sync_date_));
@ -9618,7 +9618,7 @@ void ContactsManager::on_get_contacts(tl_object_ptr<telegram_api::contacts_Conta
} }
void ContactsManager::save_contacts_to_database() { void ContactsManager::save_contacts_to_database() {
if (!G()->parameters().use_chat_info_db || !are_contacts_loaded_) { if (!G()->use_chat_info_database() || !are_contacts_loaded_) {
return; return;
} }
@ -10013,7 +10013,7 @@ class ContactsManager::UserLogEvent {
}; };
void ContactsManager::save_user(User *u, UserId user_id, bool from_binlog) { void ContactsManager::save_user(User *u, UserId user_id, bool from_binlog) {
if (!G()->parameters().use_chat_info_db) { if (!G()->use_chat_info_database()) {
return; return;
} }
CHECK(u != nullptr); CHECK(u != nullptr);
@ -10033,7 +10033,7 @@ void ContactsManager::save_user(User *u, UserId user_id, bool from_binlog) {
} }
void ContactsManager::on_binlog_user_event(BinlogEvent &&event) { void ContactsManager::on_binlog_user_event(BinlogEvent &&event) {
if (!G()->parameters().use_chat_info_db) { if (!G()->use_chat_info_database()) {
binlog_erase(G()->td_db()->get_binlog(), event.id_); binlog_erase(G()->td_db()->get_binlog(), event.id_);
return; return;
} }
@ -10306,7 +10306,7 @@ ContactsManager::User *ContactsManager::get_user_force_impl(UserId user_id) {
if (u != nullptr) { if (u != nullptr) {
return u; return u;
} }
if (!G()->parameters().use_chat_info_db) { if (!G()->use_chat_info_database()) {
return nullptr; return nullptr;
} }
if (loaded_from_database_users_.count(user_id)) { if (loaded_from_database_users_.count(user_id)) {
@ -10343,7 +10343,7 @@ class ContactsManager::ChatLogEvent {
}; };
void ContactsManager::save_chat(Chat *c, ChatId chat_id, bool from_binlog) { void ContactsManager::save_chat(Chat *c, ChatId chat_id, bool from_binlog) {
if (!G()->parameters().use_chat_info_db) { if (!G()->use_chat_info_database()) {
return; return;
} }
CHECK(c != nullptr); CHECK(c != nullptr);
@ -10364,7 +10364,7 @@ void ContactsManager::save_chat(Chat *c, ChatId chat_id, bool from_binlog) {
} }
void ContactsManager::on_binlog_chat_event(BinlogEvent &&event) { void ContactsManager::on_binlog_chat_event(BinlogEvent &&event) {
if (!G()->parameters().use_chat_info_db) { if (!G()->use_chat_info_database()) {
binlog_erase(G()->td_db()->get_binlog(), event.id_); binlog_erase(G()->td_db()->get_binlog(), event.id_);
return; return;
} }
@ -10552,7 +10552,7 @@ ContactsManager::Chat *ContactsManager::get_chat_force(ChatId chat_id) {
return c; return c;
} }
if (!G()->parameters().use_chat_info_db) { if (!G()->use_chat_info_database()) {
return nullptr; return nullptr;
} }
if (loaded_from_database_chats_.count(chat_id)) { if (loaded_from_database_chats_.count(chat_id)) {
@ -10589,7 +10589,7 @@ class ContactsManager::ChannelLogEvent {
}; };
void ContactsManager::save_channel(Channel *c, ChannelId channel_id, bool from_binlog) { void ContactsManager::save_channel(Channel *c, ChannelId channel_id, bool from_binlog) {
if (!G()->parameters().use_chat_info_db) { if (!G()->use_chat_info_database()) {
return; return;
} }
CHECK(c != nullptr); CHECK(c != nullptr);
@ -10610,7 +10610,7 @@ void ContactsManager::save_channel(Channel *c, ChannelId channel_id, bool from_b
} }
void ContactsManager::on_binlog_channel_event(BinlogEvent &&event) { void ContactsManager::on_binlog_channel_event(BinlogEvent &&event) {
if (!G()->parameters().use_chat_info_db) { if (!G()->use_chat_info_database()) {
binlog_erase(G()->td_db()->get_binlog(), event.id_); binlog_erase(G()->td_db()->get_binlog(), event.id_);
return; return;
} }
@ -10814,7 +10814,7 @@ ContactsManager::Channel *ContactsManager::get_channel_force(ChannelId channel_i
if (c != nullptr) { if (c != nullptr) {
return c; return c;
} }
if (!G()->parameters().use_chat_info_db) { if (!G()->use_chat_info_database()) {
return nullptr; return nullptr;
} }
if (loaded_from_database_channels_.count(channel_id)) { if (loaded_from_database_channels_.count(channel_id)) {
@ -10852,7 +10852,7 @@ class ContactsManager::SecretChatLogEvent {
}; };
void ContactsManager::save_secret_chat(SecretChat *c, SecretChatId secret_chat_id, bool from_binlog) { void ContactsManager::save_secret_chat(SecretChat *c, SecretChatId secret_chat_id, bool from_binlog) {
if (!G()->parameters().use_chat_info_db) { if (!G()->use_chat_info_database()) {
return; return;
} }
CHECK(c != nullptr); CHECK(c != nullptr);
@ -10873,7 +10873,7 @@ void ContactsManager::save_secret_chat(SecretChat *c, SecretChatId secret_chat_i
} }
void ContactsManager::on_binlog_secret_chat_event(BinlogEvent &&event) { void ContactsManager::on_binlog_secret_chat_event(BinlogEvent &&event) {
if (!G()->parameters().use_chat_info_db) { if (!G()->use_chat_info_database()) {
binlog_erase(G()->td_db()->get_binlog(), event.id_); binlog_erase(G()->td_db()->get_binlog(), event.id_);
return; return;
} }
@ -11064,7 +11064,7 @@ ContactsManager::SecretChat *ContactsManager::get_secret_chat_force(SecretChatId
} }
return c; return c;
} }
if (!G()->parameters().use_chat_info_db) { if (!G()->use_chat_info_database()) {
return nullptr; return nullptr;
} }
if (loaded_from_database_secret_chats_.count(secret_chat_id)) { if (loaded_from_database_secret_chats_.count(secret_chat_id)) {
@ -11078,7 +11078,7 @@ ContactsManager::SecretChat *ContactsManager::get_secret_chat_force(SecretChatId
} }
void ContactsManager::save_user_full(const UserFull *user_full, UserId user_id) { void ContactsManager::save_user_full(const UserFull *user_full, UserId user_id) {
if (!G()->parameters().use_chat_info_db) { if (!G()->use_chat_info_database()) {
return; return;
} }
@ -11160,7 +11160,7 @@ ContactsManager::UserFull *ContactsManager::get_user_full_force(UserId user_id)
if (user_full != nullptr) { if (user_full != nullptr) {
return user_full; return user_full;
} }
if (!G()->parameters().use_chat_info_db) { if (!G()->use_chat_info_database()) {
return nullptr; return nullptr;
} }
if (!unavailable_user_fulls_.insert(user_id).second) { if (!unavailable_user_fulls_.insert(user_id).second) {
@ -11174,7 +11174,7 @@ ContactsManager::UserFull *ContactsManager::get_user_full_force(UserId user_id)
} }
void ContactsManager::save_chat_full(const ChatFull *chat_full, ChatId chat_id) { void ContactsManager::save_chat_full(const ChatFull *chat_full, ChatId chat_id) {
if (!G()->parameters().use_chat_info_db) { if (!G()->use_chat_info_database()) {
return; return;
} }
@ -11268,7 +11268,7 @@ ContactsManager::ChatFull *ContactsManager::get_chat_full_force(ChatId chat_id,
if (chat_full != nullptr) { if (chat_full != nullptr) {
return chat_full; return chat_full;
} }
if (!G()->parameters().use_chat_info_db) { if (!G()->use_chat_info_database()) {
return nullptr; return nullptr;
} }
if (!unavailable_chat_fulls_.insert(chat_id).second) { if (!unavailable_chat_fulls_.insert(chat_id).second) {
@ -11282,7 +11282,7 @@ ContactsManager::ChatFull *ContactsManager::get_chat_full_force(ChatId chat_id,
} }
void ContactsManager::save_channel_full(const ChannelFull *channel_full, ChannelId channel_id) { void ContactsManager::save_channel_full(const ChannelFull *channel_full, ChannelId channel_id) {
if (!G()->parameters().use_chat_info_db) { if (!G()->use_chat_info_database()) {
return; return;
} }
@ -11412,7 +11412,7 @@ ContactsManager::ChannelFull *ContactsManager::get_channel_full_force(ChannelId
if (channel_full != nullptr) { if (channel_full != nullptr) {
return channel_full; return channel_full;
} }
if (!G()->parameters().use_chat_info_db) { if (!G()->use_chat_info_database()) {
return nullptr; return nullptr;
} }
if (!unavailable_channel_fulls_.insert(channel_id).second) { if (!unavailable_channel_fulls_.insert(channel_id).second) {
@ -12829,7 +12829,7 @@ void ContactsManager::on_update_user_phone_number(User *u, UserId user_id, strin
void ContactsManager::on_update_user_photo(User *u, UserId user_id, void ContactsManager::on_update_user_photo(User *u, UserId user_id,
tl_object_ptr<telegram_api::UserProfilePhoto> &&photo, const char *source) { tl_object_ptr<telegram_api::UserProfilePhoto> &&photo, const char *source) {
if (td_->auth_manager_->is_bot() && !G()->parameters().use_file_db && !u->is_photo_inited) { if (td_->auth_manager_->is_bot() && !G()->use_file_database() && !u->is_photo_inited) {
if (photo != nullptr && photo->get_id() == telegram_api::userProfilePhoto::ID) { if (photo != nullptr && photo->get_id() == telegram_api::userProfilePhoto::ID) {
auto *profile_photo = static_cast<telegram_api::userProfilePhoto *>(photo.get()); auto *profile_photo = static_cast<telegram_api::userProfilePhoto *>(photo.get());
if ((profile_photo->flags_ & telegram_api::userProfilePhoto::STRIPPED_THUMB_MASK) != 0) { if ((profile_photo->flags_ & telegram_api::userProfilePhoto::STRIPPED_THUMB_MASK) != 0) {
@ -15362,7 +15362,7 @@ void ContactsManager::on_channel_status_changed(Channel *c, ChannelId channel_id
channel_participants_.erase(channel_id); channel_participants_.erase(channel_id);
} }
if (td_->auth_manager_->is_bot() && old_status.is_member() && !new_status.is_member() && if (td_->auth_manager_->is_bot() && old_status.is_member() && !new_status.is_member() &&
!G()->parameters().use_message_db) { !G()->use_message_database()) {
send_closure_later(G()->messages_manager(), &MessagesManager::on_dialog_deleted, DialogId(channel_id), send_closure_later(G()->messages_manager(), &MessagesManager::on_dialog_deleted, DialogId(channel_id),
Promise<Unit>()); Promise<Unit>());
} }
@ -15784,7 +15784,7 @@ void ContactsManager::update_contacts_hints(const User *u, UserId user_id, bool
} }
} }
if (G()->parameters().use_chat_info_db) { if (G()->use_chat_info_database()) {
// update contacts database // update contacts database
if (!are_contacts_loaded_) { if (!are_contacts_loaded_) {
if (!from_database && load_contacts_queries_.empty() && is_contact && u->is_is_contact_changed) { if (!from_database && load_contacts_queries_.empty() && is_contact && u->is_is_contact_changed) {
@ -15962,7 +15962,7 @@ bool ContactsManager::get_user(UserId user_id, int left_tries, Promise<Unit> &&p
} }
if (td_->auth_manager_->is_bot() ? !have_user(user_id) : !have_min_user(user_id)) { if (td_->auth_manager_->is_bot() ? !have_user(user_id) : !have_min_user(user_id)) {
if (left_tries > 2 && G()->parameters().use_chat_info_db) { if (left_tries > 2 && G()->use_chat_info_database()) {
send_closure_later(actor_id(this), &ContactsManager::load_user_from_database, nullptr, user_id, send_closure_later(actor_id(this), &ContactsManager::load_user_from_database, nullptr, user_id,
std::move(promise)); std::move(promise));
return false; return false;
@ -16269,7 +16269,7 @@ bool ContactsManager::get_chat(ChatId chat_id, int left_tries, Promise<Unit> &&p
} }
if (!have_chat(chat_id)) { if (!have_chat(chat_id)) {
if (left_tries > 2 && G()->parameters().use_chat_info_db) { if (left_tries > 2 && G()->use_chat_info_database()) {
send_closure_later(actor_id(this), &ContactsManager::load_chat_from_database, nullptr, chat_id, send_closure_later(actor_id(this), &ContactsManager::load_chat_from_database, nullptr, chat_id,
std::move(promise)); std::move(promise));
return false; return false;
@ -16681,7 +16681,7 @@ bool ContactsManager::get_channel(ChannelId channel_id, int left_tries, Promise<
} }
if (!have_channel(channel_id)) { if (!have_channel(channel_id)) {
if (left_tries > 2 && G()->parameters().use_chat_info_db) { if (left_tries > 2 && G()->use_chat_info_database()) {
send_closure_later(actor_id(this), &ContactsManager::load_channel_from_database, nullptr, channel_id, send_closure_later(actor_id(this), &ContactsManager::load_channel_from_database, nullptr, channel_id,
std::move(promise)); std::move(promise));
return false; return false;
@ -16840,7 +16840,7 @@ bool ContactsManager::get_secret_chat(SecretChatId secret_chat_id, bool force, P
} }
if (!have_secret_chat(secret_chat_id)) { if (!have_secret_chat(secret_chat_id)) {
if (!force && G()->parameters().use_chat_info_db) { if (!force && G()->use_chat_info_database()) {
send_closure_later(actor_id(this), &ContactsManager::load_secret_chat_from_database, nullptr, secret_chat_id, send_closure_later(actor_id(this), &ContactsManager::load_secret_chat_from_database, nullptr, secret_chat_id,
std::move(promise)); std::move(promise));
return false; return false;
@ -17371,7 +17371,7 @@ void ContactsManager::get_dialog_administrators(DialogId dialog_id,
return promise.set_value(get_chat_administrators_object(it->second)); return promise.set_value(get_chat_administrators_object(it->second));
} }
if (G()->parameters().use_chat_info_db) { if (G()->use_chat_info_database()) {
LOG(INFO) << "Load administrators of " << dialog_id << " from database"; LOG(INFO) << "Load administrators of " << dialog_id << " from database";
G()->td_db()->get_sqlite_pmc()->get(get_dialog_administrators_database_key(dialog_id), G()->td_db()->get_sqlite_pmc()->get(get_dialog_administrators_database_key(dialog_id),
PromiseCreator::lambda([actor_id = actor_id(this), dialog_id, PromiseCreator::lambda([actor_id = actor_id(this), dialog_id,
@ -17478,14 +17478,14 @@ void ContactsManager::on_update_dialog_administrators(DialogId dialog_id, vector
it = dialog_administrators_.emplace(dialog_id, std::move(administrators)).first; it = dialog_administrators_.emplace(dialog_id, std::move(administrators)).first;
} }
if (G()->parameters().use_chat_info_db && !from_database) { if (G()->use_chat_info_database() && !from_database) {
LOG(INFO) << "Save administrators of " << dialog_id << " to database"; LOG(INFO) << "Save administrators of " << dialog_id << " to database";
G()->td_db()->get_sqlite_pmc()->set(get_dialog_administrators_database_key(dialog_id), G()->td_db()->get_sqlite_pmc()->set(get_dialog_administrators_database_key(dialog_id),
log_event_store(it->second).as_slice().str(), Auto()); log_event_store(it->second).as_slice().str(), Auto());
} }
} else { } else {
dialog_administrators_.erase(dialog_id); dialog_administrators_.erase(dialog_id);
if (G()->parameters().use_chat_info_db) { if (G()->use_chat_info_database()) {
G()->td_db()->get_sqlite_pmc()->erase(get_dialog_administrators_database_key(dialog_id), Auto()); G()->td_db()->get_sqlite_pmc()->erase(get_dialog_administrators_database_key(dialog_id), Auto());
} }
} }

View File

@ -367,7 +367,7 @@ class DownloadManagerImpl final : public DownloadManager {
} }
static bool is_database_enabled() { static bool is_database_enabled() {
return G()->parameters().use_message_db; return G()->use_message_database();
} }
static string pmc_key(const FileInfo &file_info) { static string pmc_key(const FileInfo &file_info) {

View File

@ -396,8 +396,20 @@ class Global final : public ActorContext {
return mtproto_header_ != nullptr; return mtproto_header_ != nullptr;
} }
const TdParameters &parameters() const { bool use_file_database() const {
return parameters_; return parameters_.use_file_db;
}
bool use_chat_info_database() const {
return parameters_.use_chat_info_db;
}
bool use_message_database() const {
return parameters_.use_message_db;
}
bool use_secret_chats() const {
return parameters_.use_secret_chats;
} }
int32 get_gc_scheduler_id() const { int32 get_gc_scheduler_id() const {

View File

@ -23,7 +23,7 @@ HashtagHints::HashtagHints(string mode, ActorShared<> parent) : mode_(std::move(
} }
void HashtagHints::start_up() { void HashtagHints::start_up() {
if (G()->parameters().use_file_db) { // TODO hashtag hints should not depend on use_file_db if (G()->use_file_database()) { // TODO hashtag hints should not depend on use_file_db
G()->td_db()->get_sqlite_pmc()->get(get_key(), G()->td_db()->get_sqlite_pmc()->get(get_key(),
PromiseCreator::lambda([actor_id = actor_id(this)](Result<string> res) { PromiseCreator::lambda([actor_id = actor_id(this)](Result<string> res) {
send_closure(actor_id, &HashtagHints::from_db, std::move(res), false); send_closure(actor_id, &HashtagHints::from_db, std::move(res), false);

View File

@ -2067,7 +2067,7 @@ bool InlineQueriesManager::load_recently_used_bots(Promise<Unit> &promise) {
if (recently_used_bots_loaded_ == 0) { if (recently_used_bots_loaded_ == 0) {
resolve_recent_inline_bots_multipromise_.set_ignore_errors(true); resolve_recent_inline_bots_multipromise_.set_ignore_errors(true);
auto lock = resolve_recent_inline_bots_multipromise_.get_promise(); auto lock = resolve_recent_inline_bots_multipromise_.get_promise();
if (!G()->parameters().use_chat_info_db) { if (!G()->use_chat_info_database()) {
for (auto &bot_username : bot_usernames) { for (auto &bot_username : bot_usernames) {
td_->messages_manager_->search_public_dialog(bot_username, false, td_->messages_manager_->search_public_dialog(bot_username, false,
resolve_recent_inline_bots_multipromise_.get_promise()); resolve_recent_inline_bots_multipromise_.get_promise());

File diff suppressed because it is too large Load Diff

View File

@ -549,7 +549,7 @@ MessageId NotificationManager::get_last_message_id_by_notification_id(const Noti
void NotificationManager::load_message_notifications_from_database(const NotificationGroupKey &group_key, void NotificationManager::load_message_notifications_from_database(const NotificationGroupKey &group_key,
NotificationGroup &group, size_t desired_size) { NotificationGroup &group, size_t desired_size) {
if (!G()->parameters().use_message_db) { if (!G()->use_message_database()) {
return; return;
} }
if (group.is_loaded_from_database || group.is_being_loaded_from_database || if (group.is_loaded_from_database || group.is_being_loaded_from_database ||
@ -3698,7 +3698,7 @@ void NotificationManager::add_message_push_notification(DialogId dialog_id, Mess
td_->contacts_manager_->on_get_user(std::move(user), "add_message_push_notification"); td_->contacts_manager_->on_get_user(std::move(user), "add_message_push_notification");
} }
if (log_event_id == 0 && G()->parameters().use_message_db) { if (log_event_id == 0 && G()->use_message_database()) {
AddMessagePushNotificationLogEvent log_event{dialog_id, AddMessagePushNotificationLogEvent log_event{dialog_id,
message_id, message_id,
random_id, random_id,
@ -3841,7 +3841,7 @@ void NotificationManager::edit_message_push_notification(DialogId dialog_id, Mes
CHECK(group_id.is_valid()); CHECK(group_id.is_valid());
CHECK(notification_id.is_valid()); CHECK(notification_id.is_valid());
if (log_event_id == 0 && G()->parameters().use_message_db) { if (log_event_id == 0 && G()->use_message_database()) {
EditMessagePushNotificationLogEvent log_event{dialog_id, message_id, edit_date, loc_key, arg, photo, document}; EditMessagePushNotificationLogEvent log_event{dialog_id, message_id, edit_date, loc_key, arg, photo, document};
auto storer = get_log_event_storer(log_event); auto storer = get_log_event_storer(log_event);
auto &cur_log_event_id = temporary_edit_notification_log_event_ids_[notification_id]; auto &cur_log_event_id = temporary_edit_notification_log_event_ids_[notification_id];
@ -4185,7 +4185,7 @@ void NotificationManager::on_binlog_events(vector<BinlogEvent> &&events) {
} }
VLOG(notifications) << "Begin to process " << events.size() << " binlog events"; VLOG(notifications) << "Begin to process " << events.size() << " binlog events";
for (auto &event : events) { for (auto &event : events) {
if (!G()->parameters().use_message_db || is_disabled() || max_notification_group_count_ == 0) { if (!G()->use_message_database() || is_disabled() || max_notification_group_count_ == 0) {
binlog_erase(G()->td_db()->get_binlog(), event.id_); binlog_erase(G()->td_db()->get_binlog(), event.id_);
break; break;
} }

View File

@ -357,7 +357,7 @@ void PollManager::save_poll(const Poll *poll, PollId poll_id) {
CHECK(!is_local_poll_id(poll_id)); CHECK(!is_local_poll_id(poll_id));
poll->was_saved = true; poll->was_saved = true;
if (!G()->parameters().use_message_db) { if (!G()->use_message_database()) {
return; return;
} }
@ -405,7 +405,7 @@ PollManager::Poll *PollManager::get_poll_force(PollId poll_id) {
if (poll != nullptr) { if (poll != nullptr) {
return poll; return poll;
} }
if (!G()->parameters().use_message_db) { if (!G()->use_message_database()) {
return nullptr; return nullptr;
} }
if (!poll_id.is_valid() || loaded_from_database_polls_.count(poll_id)) { if (!poll_id.is_valid() || loaded_from_database_polls_.count(poll_id)) {
@ -844,7 +844,7 @@ void PollManager::do_set_poll_answer(PollId poll_id, FullMessageId full_message_
binlog_erase(G()->td_db()->get_binlog(), log_event_id); binlog_erase(G()->td_db()->get_binlog(), log_event_id);
return; return;
} }
if (log_event_id == 0 && G()->parameters().use_message_db) { if (log_event_id == 0 && G()->use_message_database()) {
SetPollAnswerLogEvent log_event; SetPollAnswerLogEvent log_event;
log_event.poll_id_ = poll_id; log_event.poll_id_ = poll_id;
log_event.full_message_id_ = full_message_id; log_event.full_message_id_ = full_message_id;
@ -1201,7 +1201,7 @@ void PollManager::do_stop_poll(PollId poll_id, FullMessageId full_message_id, un
LOG(INFO) << "Stop " << poll_id << " from " << full_message_id; LOG(INFO) << "Stop " << poll_id << " from " << full_message_id;
CHECK(poll_id.is_valid()); CHECK(poll_id.is_valid());
if (log_event_id == 0 && G()->parameters().use_message_db && reply_markup == nullptr) { if (log_event_id == 0 && G()->use_message_database() && reply_markup == nullptr) {
StopPollLogEvent log_event{poll_id, full_message_id}; StopPollLogEvent log_event{poll_id, full_message_id};
log_event_id = log_event_id =
binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::StopPoll, get_log_event_storer(log_event)); binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::StopPoll, get_log_event_storer(log_event));
@ -1823,7 +1823,7 @@ void PollManager::on_binlog_events(vector<BinlogEvent> &&events) {
for (auto &event : events) { for (auto &event : events) {
switch (event.type_) { switch (event.type_) {
case LogEvent::HandlerType::SetPollAnswer: { case LogEvent::HandlerType::SetPollAnswer: {
if (!G()->parameters().use_message_db) { if (!G()->use_message_database()) {
binlog_erase(G()->td_db()->get_binlog(), event.id_); binlog_erase(G()->td_db()->get_binlog(), event.id_);
break; break;
} }
@ -1842,7 +1842,7 @@ void PollManager::on_binlog_events(vector<BinlogEvent> &&events) {
break; break;
} }
case LogEvent::HandlerType::StopPoll: { case LogEvent::HandlerType::StopPoll: {
if (!G()->parameters().use_message_db) { if (!G()->use_message_database()) {
binlog_erase(G()->td_db()->get_binlog(), event.id_); binlog_erase(G()->td_db()->get_binlog(), event.id_);
break; break;
} }

View File

@ -46,7 +46,7 @@ void RecentDialogList::save_dialogs() const {
SliceBuilder sb; SliceBuilder sb;
for (auto &dialog_id : dialog_ids_) { for (auto &dialog_id : dialog_ids_) {
sb << ','; sb << ',';
if (!G()->parameters().use_chat_info_db) { if (!G()->use_chat_info_database()) {
// if there is no dialog info database, prefer to save dialogs by username // if there is no dialog info database, prefer to save dialogs by username
string username; string username;
switch (dialog_id.get_type()) { switch (dialog_id.get_type()) {
@ -107,7 +107,7 @@ void RecentDialogList::load_dialogs(Promise<Unit> &&promise) {
} }
} }
if (!dialog_ids.empty()) { if (!dialog_ids.empty()) {
if (G()->parameters().use_chat_info_db) { if (G()->use_chat_info_database()) {
td_->messages_manager_->load_dialogs( td_->messages_manager_->load_dialogs(
std::move(dialog_ids), std::move(dialog_ids),
PromiseCreator::lambda( PromiseCreator::lambda(

View File

@ -74,7 +74,7 @@ SecretChatsManager::SecretChatsManager(ActorShared<> parent) : parent_(std::move
} }
void SecretChatsManager::start_up() { void SecretChatsManager::start_up() {
if (!G()->parameters().use_secret_chats) { if (!G()->use_secret_chats()) {
dummy_mode_ = true; dummy_mode_ = true;
return; return;
} }

View File

@ -1791,7 +1791,7 @@ void StickersManager::init() {
} }
load_special_sticker_set(add_special_sticker_set(SpecialStickerSetType::premium_gifts())); load_special_sticker_set(add_special_sticker_set(SpecialStickerSetType::premium_gifts()));
if (G()->parameters().use_file_db) { if (G()->use_file_database()) {
auto old_featured_sticker_set_count_str = G()->td_db()->get_binlog_pmc()->get("old_featured_sticker_set_count"); auto old_featured_sticker_set_count_str = G()->td_db()->get_binlog_pmc()->get("old_featured_sticker_set_count");
if (!old_featured_sticker_set_count_str.empty()) { if (!old_featured_sticker_set_count_str.empty()) {
old_featured_sticker_set_count_[static_cast<int32>(StickerType::Regular)] = old_featured_sticker_set_count_[static_cast<int32>(StickerType::Regular)] =
@ -1931,7 +1931,7 @@ void StickersManager::init_special_sticker_set(SpecialStickerSet &sticker_set, i
} }
void StickersManager::load_special_sticker_set_info_from_binlog(SpecialStickerSet &sticker_set) { void StickersManager::load_special_sticker_set_info_from_binlog(SpecialStickerSet &sticker_set) {
if (G()->parameters().use_file_db) { if (G()->use_file_database()) {
string sticker_set_string = G()->td_db()->get_binlog_pmc()->get(sticker_set.type_.type_); string sticker_set_string = G()->td_db()->get_binlog_pmc()->get(sticker_set.type_.type_);
if (!sticker_set_string.empty()) { if (!sticker_set_string.empty()) {
auto parts = full_split(sticker_set_string); auto parts = full_split(sticker_set_string);
@ -3042,7 +3042,7 @@ FileId StickersManager::on_get_sticker(unique_ptr<Sticker> new_sticker, bool rep
custom_emoji_to_sticker_id_.set(custom_emoji_id, file_id); custom_emoji_to_sticker_id_.set(custom_emoji_id, file_id);
CHECK(updated_custom_emoji_id == custom_emoji_id || !updated_custom_emoji_id.is_valid()); CHECK(updated_custom_emoji_id == custom_emoji_id || !updated_custom_emoji_id.is_valid());
updated_custom_emoji_id = custom_emoji_id; updated_custom_emoji_id = custom_emoji_id;
if (!s->is_from_database_ && G()->parameters().use_file_db && !G()->close_flag()) { if (!s->is_from_database_ && G()->use_file_database() && !G()->close_flag()) {
LOG(INFO) << "Save " << custom_emoji_id << " to database"; LOG(INFO) << "Save " << custom_emoji_id << " to database";
s->is_from_database_ = true; s->is_from_database_ = true;
@ -4942,7 +4942,7 @@ void StickersManager::search_stickers(StickerType sticker_type, string emoji, in
get_recent_stickers_hash(it->second.sticker_ids_, "search_stickers")); get_recent_stickers_hash(it->second.sticker_ids_, "search_stickers"));
} }
if (G()->parameters().use_file_db) { if (G()->use_file_database()) {
LOG(INFO) << "Trying to load stickers for " << emoji << " from database"; LOG(INFO) << "Trying to load stickers for " << emoji << " from database";
G()->td_db()->get_sqlite_pmc()->get(get_found_stickers_database_key(sticker_type, emoji), G()->td_db()->get_sqlite_pmc()->get(get_found_stickers_database_key(sticker_type, emoji),
PromiseCreator::lambda([sticker_type, emoji](string value) mutable { PromiseCreator::lambda([sticker_type, emoji](string value) mutable {
@ -5018,7 +5018,7 @@ void StickersManager::on_search_stickers_succeeded(StickerType sticker_type, con
found_stickers.next_reload_time_ = Time::now() + found_stickers.cache_time_; found_stickers.next_reload_time_ = Time::now() + found_stickers.cache_time_;
found_stickers.sticker_ids_ = std::move(sticker_ids); found_stickers.sticker_ids_ = std::move(sticker_ids);
if (G()->parameters().use_file_db && !G()->close_flag()) { if (G()->use_file_database() && !G()->close_flag()) {
LOG(INFO) << "Save " << sticker_type << " stickers for " << emoji << " to database"; LOG(INFO) << "Save " << sticker_type << " stickers for " << emoji << " to database";
G()->td_db()->get_sqlite_pmc()->set(get_found_stickers_database_key(sticker_type, emoji), G()->td_db()->get_sqlite_pmc()->set(get_found_stickers_database_key(sticker_type, emoji),
log_event_store(found_stickers).as_slice().str(), Auto()); log_event_store(found_stickers).as_slice().str(), Auto());
@ -5492,7 +5492,7 @@ void StickersManager::load_installed_sticker_sets(StickerType sticker_type, Prom
} }
load_installed_sticker_sets_queries_[type].push_back(std::move(promise)); load_installed_sticker_sets_queries_[type].push_back(std::move(promise));
if (load_installed_sticker_sets_queries_[type].size() == 1u) { if (load_installed_sticker_sets_queries_[type].size() == 1u) {
if (G()->parameters().use_file_db) { if (G()->use_file_database()) {
LOG(INFO) << "Trying to load installed " << sticker_type << " sticker sets from database"; LOG(INFO) << "Trying to load installed " << sticker_type << " sticker sets from database";
G()->td_db()->get_sqlite_pmc()->get( G()->td_db()->get_sqlite_pmc()->get(
PSTRING() << "sss" << type, PromiseCreator::lambda([sticker_type](string value) { PSTRING() << "sss" << type, PromiseCreator::lambda([sticker_type](string value) {
@ -5619,7 +5619,7 @@ string StickersManager::get_sticker_set_database_value(const StickerSet *s, bool
void StickersManager::update_sticker_set(StickerSet *sticker_set, const char *source) { void StickersManager::update_sticker_set(StickerSet *sticker_set, const char *source) {
CHECK(sticker_set != nullptr); CHECK(sticker_set != nullptr);
if (sticker_set->is_changed_ || sticker_set->need_save_to_database_) { if (sticker_set->is_changed_ || sticker_set->need_save_to_database_) {
if (G()->parameters().use_file_db && !G()->close_flag()) { if (G()->use_file_database() && !G()->close_flag()) {
LOG(INFO) << "Save " << sticker_set->id_ << " to database from " << source; LOG(INFO) << "Save " << sticker_set->id_ << " to database from " << source;
if (sticker_set->is_inited_) { if (sticker_set->is_inited_) {
G()->td_db()->get_sqlite_pmc()->set(get_sticker_set_database_key(sticker_set->id_), G()->td_db()->get_sqlite_pmc()->set(get_sticker_set_database_key(sticker_set->id_),
@ -5661,7 +5661,7 @@ void StickersManager::load_sticker_sets(vector<StickerSetId> &&sticker_set_ids,
sticker_set->load_requests_.push_back(load_request_id); sticker_set->load_requests_.push_back(load_request_id);
if (sticker_set->load_requests_.size() == 1u) { if (sticker_set->load_requests_.size() == 1u) {
if (G()->parameters().use_file_db && !sticker_set->was_loaded_) { if (G()->use_file_database() && !sticker_set->was_loaded_) {
LOG(INFO) << "Trying to load " << sticker_set_id << " with stickers from database"; LOG(INFO) << "Trying to load " << sticker_set_id << " with stickers from database";
G()->td_db()->get_sqlite_pmc()->get( G()->td_db()->get_sqlite_pmc()->get(
get_full_sticker_set_database_key(sticker_set_id), PromiseCreator::lambda([sticker_set_id](string value) { get_full_sticker_set_database_key(sticker_set_id), PromiseCreator::lambda([sticker_set_id](string value) {
@ -5699,7 +5699,7 @@ void StickersManager::load_sticker_sets_without_stickers(vector<StickerSetId> &&
} else { } else {
sticker_set->load_without_stickers_requests_.push_back(load_request_id); sticker_set->load_without_stickers_requests_.push_back(load_request_id);
if (sticker_set->load_without_stickers_requests_.size() == 1u) { if (sticker_set->load_without_stickers_requests_.size() == 1u) {
if (G()->parameters().use_file_db) { if (G()->use_file_database()) {
LOG(INFO) << "Trying to load " << sticker_set_id << " from database"; LOG(INFO) << "Trying to load " << sticker_set_id << " from database";
G()->td_db()->get_sqlite_pmc()->get( G()->td_db()->get_sqlite_pmc()->get(
get_sticker_set_database_key(sticker_set_id), PromiseCreator::lambda([sticker_set_id](string value) { get_sticker_set_database_key(sticker_set_id), PromiseCreator::lambda([sticker_set_id](string value) {
@ -5923,7 +5923,7 @@ void StickersManager::on_update_dice_emojis() {
special_sticker_set.short_name_.clear(); special_sticker_set.short_name_.clear();
} }
if (G()->parameters().use_file_db) { if (G()->use_file_database()) {
LOG(INFO) << "Load new dice sticker set for emoji " << emoji; LOG(INFO) << "Load new dice sticker set for emoji " << emoji;
load_special_sticker_set(special_sticker_set); load_special_sticker_set(special_sticker_set);
} }
@ -6446,7 +6446,7 @@ void StickersManager::get_default_topic_icons(bool is_recursive,
} }
void StickersManager::load_custom_emoji_sticker_from_database_force(CustomEmojiId custom_emoji_id) { void StickersManager::load_custom_emoji_sticker_from_database_force(CustomEmojiId custom_emoji_id) {
if (!G()->parameters().use_file_db) { if (!G()->use_file_database()) {
return; return;
} }
@ -6466,7 +6466,7 @@ void StickersManager::load_custom_emoji_sticker_from_database_force(CustomEmojiI
void StickersManager::load_custom_emoji_sticker_from_database(CustomEmojiId custom_emoji_id, Promise<Unit> &&promise) { void StickersManager::load_custom_emoji_sticker_from_database(CustomEmojiId custom_emoji_id, Promise<Unit> &&promise) {
CHECK(custom_emoji_id.is_valid()); CHECK(custom_emoji_id.is_valid());
if (!G()->parameters().use_file_db) { if (!G()->use_file_database()) {
return promise.set_value(Unit()); return promise.set_value(Unit());
} }
@ -6622,7 +6622,7 @@ void StickersManager::get_custom_emoji_stickers(vector<CustomEmojiId> custom_emo
return promise.set_value(get_custom_emoji_stickers_object(custom_emoji_ids)); return promise.set_value(get_custom_emoji_stickers_object(custom_emoji_ids));
} }
if (use_database && G()->parameters().use_file_db) { if (use_database && G()->use_file_database()) {
MultiPromiseActorSafe mpas{"LoadCustomEmojiMultiPromiseActor"}; MultiPromiseActorSafe mpas{"LoadCustomEmojiMultiPromiseActor"};
mpas.add_promise(PromiseCreator::lambda( mpas.add_promise(PromiseCreator::lambda(
[actor_id = actor_id(this), custom_emoji_ids, promise = std::move(promise)](Unit) mutable { [actor_id = actor_id(this), custom_emoji_ids, promise = std::move(promise)](Unit) mutable {
@ -6686,7 +6686,7 @@ void StickersManager::get_default_dialog_photo_custom_emoji_stickers(
return; return;
} }
if (G()->parameters().use_file_db && !are_default_dialog_photo_custom_emoji_ids_loaded_[for_user]) { if (G()->use_file_database() && !are_default_dialog_photo_custom_emoji_ids_loaded_[for_user]) {
LOG(INFO) << "Trying to load " << (for_user ? "profile" : "chat") LOG(INFO) << "Trying to load " << (for_user ? "profile" : "chat")
<< " photo custom emoji identifiers from database"; << " photo custom emoji identifiers from database";
return G()->td_db()->get_sqlite_pmc()->get( return G()->td_db()->get_sqlite_pmc()->get(
@ -6806,7 +6806,7 @@ void StickersManager::on_get_default_dialog_photo_custom_emoji_ids(
transform(std::move(emoji_list->document_id_), [](int64 document_id) { return CustomEmojiId(document_id); }); transform(std::move(emoji_list->document_id_), [](int64 document_id) { return CustomEmojiId(document_id); });
auto hash = emoji_list->hash_; auto hash = emoji_list->hash_;
if (G()->parameters().use_file_db) { if (G()->use_file_database()) {
CustomEmojiIdsLogEvent log_event(custom_emoji_ids, hash); CustomEmojiIdsLogEvent log_event(custom_emoji_ids, hash);
G()->td_db()->get_sqlite_pmc()->set(get_default_dialog_photo_custom_emoji_ids_database_key(for_user), G()->td_db()->get_sqlite_pmc()->set(get_default_dialog_photo_custom_emoji_ids_database_key(for_user),
log_event_store(log_event).as_slice().str(), Auto()); log_event_store(log_event).as_slice().str(), Auto());
@ -7446,7 +7446,7 @@ void StickersManager::on_old_featured_sticker_sets_invalidated(StickerType stick
LOG(INFO) << "Invalidate old trending sticker sets"; LOG(INFO) << "Invalidate old trending sticker sets";
are_old_featured_sticker_sets_invalidated_[type] = true; are_old_featured_sticker_sets_invalidated_[type] = true;
if (!G()->parameters().use_file_db) { if (!G()->use_file_database()) {
return; return;
} }
@ -7463,7 +7463,7 @@ void StickersManager::invalidate_old_featured_sticker_sets(StickerType sticker_t
auto type = static_cast<int32>(sticker_type); auto type = static_cast<int32>(sticker_type);
LOG(INFO) << "Invalidate old featured sticker sets"; LOG(INFO) << "Invalidate old featured sticker sets";
if (G()->parameters().use_file_db) { if (G()->use_file_database()) {
G()->td_db()->get_binlog_pmc()->erase("invalidate_old_featured_sticker_sets"); G()->td_db()->get_binlog_pmc()->erase("invalidate_old_featured_sticker_sets");
G()->td_db()->get_sqlite_pmc()->erase_by_prefix("sssoldfeatured", Auto()); G()->td_db()->get_sqlite_pmc()->erase_by_prefix("sssoldfeatured", Auto());
} }
@ -7488,7 +7488,7 @@ void StickersManager::set_old_featured_sticker_set_count(StickerType sticker_typ
old_featured_sticker_set_count_[type] = count; old_featured_sticker_set_count_[type] = count;
need_update_featured_sticker_sets_[type] = true; need_update_featured_sticker_sets_[type] = true;
if (!G()->parameters().use_file_db) { if (!G()->use_file_database()) {
return; return;
} }
@ -7579,7 +7579,7 @@ void StickersManager::on_get_featured_sticker_sets(
if (offset >= 0) { if (offset >= 0) {
if (generation == old_featured_sticker_set_generation_[type] && sticker_type == StickerType::Regular) { if (generation == old_featured_sticker_set_generation_[type] && sticker_type == StickerType::Regular) {
if (G()->parameters().use_file_db && !G()->close_flag()) { if (G()->use_file_database() && !G()->close_flag()) {
LOG(INFO) << "Save old trending sticker sets to database with offset " LOG(INFO) << "Save old trending sticker sets to database with offset "
<< old_featured_sticker_set_ids_[type].size(); << old_featured_sticker_set_ids_[type].size();
CHECK(old_featured_sticker_set_ids_[type].size() % OLD_FEATURED_STICKER_SET_SLICE_SIZE == 0); CHECK(old_featured_sticker_set_ids_[type].size() % OLD_FEATURED_STICKER_SET_SLICE_SIZE == 0);
@ -7599,7 +7599,7 @@ void StickersManager::on_get_featured_sticker_sets(
LOG_IF(ERROR, featured_sticker_sets_hash_[type] != featured_stickers->hash_) << "Trending sticker sets hash mismatch"; LOG_IF(ERROR, featured_sticker_sets_hash_[type] != featured_stickers->hash_) << "Trending sticker sets hash mismatch";
if (G()->parameters().use_file_db && !G()->close_flag()) { if (G()->use_file_database() && !G()->close_flag()) {
LOG(INFO) << "Save trending sticker sets to database"; LOG(INFO) << "Save trending sticker sets to database";
StickerSetListLogEvent log_event(featured_sticker_set_ids_[type], are_featured_sticker_sets_premium_[type]); StickerSetListLogEvent log_event(featured_sticker_set_ids_[type], are_featured_sticker_sets_premium_[type]);
G()->td_db()->get_sqlite_pmc()->set(PSTRING() << "sssfeatured" << get_featured_sticker_suffix(sticker_type), G()->td_db()->get_sqlite_pmc()->set(PSTRING() << "sssfeatured" << get_featured_sticker_suffix(sticker_type),
@ -7635,7 +7635,7 @@ void StickersManager::load_featured_sticker_sets(StickerType sticker_type, Promi
} }
load_featured_sticker_sets_queries_[type].push_back(std::move(promise)); load_featured_sticker_sets_queries_[type].push_back(std::move(promise));
if (load_featured_sticker_sets_queries_[type].size() == 1u) { if (load_featured_sticker_sets_queries_[type].size() == 1u) {
if (G()->parameters().use_file_db) { if (G()->use_file_database()) {
LOG(INFO) << "Trying to load trending sticker sets from database"; LOG(INFO) << "Trying to load trending sticker sets from database";
G()->td_db()->get_sqlite_pmc()->get(PSTRING() << "sssfeatured" << get_featured_sticker_suffix(sticker_type), G()->td_db()->get_sqlite_pmc()->get(PSTRING() << "sssfeatured" << get_featured_sticker_suffix(sticker_type),
PromiseCreator::lambda([sticker_type](string value) { PromiseCreator::lambda([sticker_type](string value) {
@ -7716,7 +7716,7 @@ void StickersManager::load_old_featured_sticker_sets(StickerType sticker_type, P
CHECK(old_featured_sticker_set_ids_[type].size() % OLD_FEATURED_STICKER_SET_SLICE_SIZE == 0); CHECK(old_featured_sticker_set_ids_[type].size() % OLD_FEATURED_STICKER_SET_SLICE_SIZE == 0);
load_old_featured_sticker_sets_queries_.push_back(std::move(promise)); load_old_featured_sticker_sets_queries_.push_back(std::move(promise));
if (load_old_featured_sticker_sets_queries_.size() == 1u) { if (load_old_featured_sticker_sets_queries_.size() == 1u) {
if (G()->parameters().use_file_db) { if (G()->use_file_database()) {
LOG(INFO) << "Trying to load old trending sticker sets from database with offset " LOG(INFO) << "Trying to load old trending sticker sets from database with offset "
<< old_featured_sticker_set_ids_[type].size(); << old_featured_sticker_set_ids_[type].size();
G()->td_db()->get_sqlite_pmc()->get( G()->td_db()->get_sqlite_pmc()->get(
@ -8904,7 +8904,7 @@ void StickersManager::send_update_installed_sticker_sets(bool from_database) {
installed_sticker_sets_hash_[type] = get_sticker_sets_hash(installed_sticker_set_ids_[type]); installed_sticker_sets_hash_[type] = get_sticker_sets_hash(installed_sticker_set_ids_[type]);
send_closure(G()->td(), &Td::send_update, get_update_installed_sticker_sets_object(sticker_type)); send_closure(G()->td(), &Td::send_update, get_update_installed_sticker_sets_object(sticker_type));
if (G()->parameters().use_file_db && !from_database && !G()->close_flag()) { if (G()->use_file_database() && !from_database && !G()->close_flag()) {
LOG(INFO) << "Save installed " << sticker_type << " sticker sets to database"; LOG(INFO) << "Save installed " << sticker_type << " sticker sets to database";
StickerSetListLogEvent log_event(installed_sticker_set_ids_[type], false); StickerSetListLogEvent log_event(installed_sticker_set_ids_[type], false);
G()->td_db()->get_sqlite_pmc()->set(PSTRING() << "sss" << type, log_event_store(log_event).as_slice().str(), G()->td_db()->get_sqlite_pmc()->set(PSTRING() << "sss" << type, log_event_store(log_event).as_slice().str(),
@ -9028,7 +9028,7 @@ void StickersManager::load_recent_stickers(bool is_attached, Promise<Unit> &&pro
} }
load_recent_stickers_queries_[is_attached].push_back(std::move(promise)); load_recent_stickers_queries_[is_attached].push_back(std::move(promise));
if (load_recent_stickers_queries_[is_attached].size() == 1u) { if (load_recent_stickers_queries_[is_attached].size() == 1u) {
if (G()->parameters().use_file_db) { if (G()->use_file_database()) {
LOG(INFO) << "Trying to load recent " << (is_attached ? "attached " : "") << "stickers from database"; LOG(INFO) << "Trying to load recent " << (is_attached ? "attached " : "") << "stickers from database";
G()->td_db()->get_sqlite_pmc()->get( G()->td_db()->get_sqlite_pmc()->get(
is_attached ? "ssr1" : "ssr0", PromiseCreator::lambda([is_attached](string value) { is_attached ? "ssr1" : "ssr0", PromiseCreator::lambda([is_attached](string value) {
@ -9332,7 +9332,7 @@ void StickersManager::send_update_recent_stickers(bool is_attached, bool from_da
} }
void StickersManager::save_recent_stickers_to_database(bool is_attached) { void StickersManager::save_recent_stickers_to_database(bool is_attached) {
if (G()->parameters().use_file_db && !G()->close_flag()) { if (G()->use_file_database() && !G()->close_flag()) {
LOG(INFO) << "Save recent " << (is_attached ? "attached " : "") << "stickers to database"; LOG(INFO) << "Save recent " << (is_attached ? "attached " : "") << "stickers to database";
StickerListLogEvent log_event(recent_sticker_ids_[is_attached]); StickerListLogEvent log_event(recent_sticker_ids_[is_attached]);
G()->td_db()->get_sqlite_pmc()->set(is_attached ? "ssr1" : "ssr0", log_event_store(log_event).as_slice().str(), G()->td_db()->get_sqlite_pmc()->set(is_attached ? "ssr1" : "ssr0", log_event_store(log_event).as_slice().str(),
@ -9426,7 +9426,7 @@ void StickersManager::load_favorite_stickers(Promise<Unit> &&promise) {
} }
load_favorite_stickers_queries_.push_back(std::move(promise)); load_favorite_stickers_queries_.push_back(std::move(promise));
if (load_favorite_stickers_queries_.size() == 1u) { if (load_favorite_stickers_queries_.size() == 1u) {
if (G()->parameters().use_file_db) { if (G()->use_file_database()) {
LOG(INFO) << "Trying to load favorite stickers from database"; LOG(INFO) << "Trying to load favorite stickers from database";
G()->td_db()->get_sqlite_pmc()->get("ssfav", PromiseCreator::lambda([](string value) { G()->td_db()->get_sqlite_pmc()->get("ssfav", PromiseCreator::lambda([](string value) {
send_closure(G()->stickers_manager(), send_closure(G()->stickers_manager(),
@ -9696,7 +9696,7 @@ void StickersManager::send_update_favorite_stickers(bool from_database) {
} }
void StickersManager::save_favorite_stickers_to_database() { void StickersManager::save_favorite_stickers_to_database() {
if (G()->parameters().use_file_db && !G()->close_flag()) { if (G()->use_file_database() && !G()->close_flag()) {
LOG(INFO) << "Save favorite stickers to database"; LOG(INFO) << "Save favorite stickers to database";
StickerListLogEvent log_event(favorite_sticker_ids_); StickerListLogEvent log_event(favorite_sticker_ids_);
G()->td_db()->get_sqlite_pmc()->set("ssfav", log_event_store(log_event).as_slice().str(), Auto()); G()->td_db()->get_sqlite_pmc()->set("ssfav", log_event_store(log_event).as_slice().str(), Auto());
@ -9866,7 +9866,7 @@ void StickersManager::on_get_language_codes(const string &key, Result<vector<str
if (it->second != language_codes) { if (it->second != language_codes) {
LOG(INFO) << "Update emoji language codes for " << key << " to " << language_codes; LOG(INFO) << "Update emoji language codes for " << key << " to " << language_codes;
if (!G()->close_flag()) { if (!G()->close_flag()) {
CHECK(G()->parameters().use_file_db); CHECK(G()->use_file_database());
G()->td_db()->get_sqlite_pmc()->set(key, implode(language_codes, '$'), Auto()); G()->td_db()->get_sqlite_pmc()->set(key, implode(language_codes, '$'), Auto());
} }
it->second = std::move(language_codes); it->second = std::move(language_codes);
@ -10017,7 +10017,7 @@ void StickersManager::on_get_emoji_keywords(
} }
} }
if (is_good && !G()->close_flag()) { if (is_good && !G()->close_flag()) {
CHECK(G()->parameters().use_file_db); CHECK(G()->use_file_database());
G()->td_db()->get_sqlite_pmc()->set(get_language_emojis_database_key(language_code, text), G()->td_db()->get_sqlite_pmc()->set(get_language_emojis_database_key(language_code, text),
implode(keyword->emoticons_, '$'), mpas.get_promise()); implode(keyword->emoticons_, '$'), mpas.get_promise());
} }
@ -10031,7 +10031,7 @@ void StickersManager::on_get_emoji_keywords(
} }
} }
if (!G()->close_flag()) { if (!G()->close_flag()) {
CHECK(G()->parameters().use_file_db); CHECK(G()->use_file_database());
G()->td_db()->get_sqlite_pmc()->set(get_emoji_language_code_version_database_key(language_code), to_string(version), G()->td_db()->get_sqlite_pmc()->set(get_emoji_language_code_version_database_key(language_code), to_string(version),
mpas.get_promise()); mpas.get_promise());
G()->td_db()->get_sqlite_pmc()->set(get_emoji_language_code_last_difference_time_database_key(language_code), G()->td_db()->get_sqlite_pmc()->set(get_emoji_language_code_last_difference_time_database_key(language_code),
@ -10140,7 +10140,7 @@ void StickersManager::on_get_emoji_keywords_difference(
UNREACHABLE(); UNREACHABLE();
} }
} }
CHECK(G()->parameters().use_file_db); CHECK(G()->use_file_database());
G()->td_db()->get_sqlite_pmc()->set_all( G()->td_db()->get_sqlite_pmc()->set_all(
std::move(key_values), PromiseCreator::lambda([actor_id = actor_id(this), language_code, version](Unit) mutable { std::move(key_values), PromiseCreator::lambda([actor_id = actor_id(this), language_code, version](Unit) mutable {
send_closure(actor_id, &StickersManager::finish_get_emoji_keywords_difference, std::move(language_code), send_closure(actor_id, &StickersManager::finish_get_emoji_keywords_difference, std::move(language_code),
@ -10161,7 +10161,7 @@ void StickersManager::finish_get_emoji_keywords_difference(string language_code,
vector<string> StickersManager::search_emojis(const string &text, bool exact_match, vector<string> StickersManager::search_emojis(const string &text, bool exact_match,
const vector<string> &input_language_codes, bool force, const vector<string> &input_language_codes, bool force,
Promise<Unit> &&promise) { Promise<Unit> &&promise) {
if (text.empty() || !G()->parameters().use_file_db /* have SQLite PMC */) { if (text.empty() || !G()->use_file_database() /* have SQLite PMC */) {
promise.set_value(Unit()); promise.set_value(Unit());
return {}; return {};
} }
@ -10276,7 +10276,7 @@ void StickersManager::get_emoji_groups(EmojiGroupType group_type,
return; return;
} }
if (G()->parameters().use_file_db /* have SQLite PMC */) { if (G()->use_file_database() /* have SQLite PMC */) {
G()->td_db()->get_sqlite_pmc()->get( G()->td_db()->get_sqlite_pmc()->get(
get_emoji_groups_database_key(group_type), get_emoji_groups_database_key(group_type),
PromiseCreator::lambda( PromiseCreator::lambda(
@ -10380,7 +10380,7 @@ void StickersManager::on_get_emoji_groups(
auto groups = telegram_api::move_object_as<telegram_api::messages_emojiGroups>(emoji_groups); auto groups = telegram_api::move_object_as<telegram_api::messages_emojiGroups>(emoji_groups);
EmojiGroupList group_list = EmojiGroupList(used_language_codes, groups->hash_, std::move(groups->groups_)); EmojiGroupList group_list = EmojiGroupList(used_language_codes, groups->hash_, std::move(groups->groups_));
if (!used_language_codes.empty() && G()->parameters().use_file_db /* have SQLite PMC */) { if (!used_language_codes.empty() && G()->use_file_database() /* have SQLite PMC */) {
G()->td_db()->get_sqlite_pmc()->set(get_emoji_groups_database_key(group_type), G()->td_db()->get_sqlite_pmc()->set(get_emoji_groups_database_key(group_type),
log_event_store(group_list).as_slice().str(), Auto()); log_event_store(group_list).as_slice().str(), Auto());
} }

View File

@ -529,7 +529,7 @@ void TopDialogManager::init() {
return; return;
} }
is_active_ = G()->parameters().use_chat_info_db && !td_->auth_manager_->is_bot(); is_active_ = G()->use_chat_info_database() && !td_->auth_manager_->is_bot();
is_enabled_ = !G()->get_option_boolean("disable_top_chats"); is_enabled_ = !G()->get_option_boolean("disable_top_chats");
update_rating_e_decay(); update_rating_e_decay();

View File

@ -1507,8 +1507,7 @@ void UpdatesManager::init_state() {
return; return;
} }
bool drop_state = !G()->parameters().use_file_db && !G()->parameters().use_secret_chats && bool drop_state = !G()->use_file_database() && !G()->use_secret_chats() && td_->auth_manager_->is_bot() &&
td_->auth_manager_->is_bot() &&
td_->option_manager_->get_option_integer("since_last_open") >= 2 * 86400; td_->option_manager_->get_option_integer("since_last_open") >= 2 * 86400;
auto pmc = G()->td_db()->get_binlog_pmc(); auto pmc = G()->td_db()->get_binlog_pmc();

View File

@ -450,7 +450,7 @@ WebPageId WebPagesManager::on_get_web_page(tl_object_ptr<telegram_api::WebPage>
} }
on_web_page_changed(web_page_id, false); on_web_page_changed(web_page_id, false);
if (G()->parameters().use_message_db) { if (G()->use_message_database()) {
LOG(INFO) << "Delete " << web_page_id << " from database"; LOG(INFO) << "Delete " << web_page_id << " from database";
G()->td_db()->get_sqlite_pmc()->erase(get_web_page_database_key(web_page_id), Auto()); G()->td_db()->get_sqlite_pmc()->erase(get_web_page_database_key(web_page_id), Auto());
G()->td_db()->get_sqlite_pmc()->erase(get_web_page_instant_view_database_key(web_page_id), Auto()); G()->td_db()->get_sqlite_pmc()->erase(get_web_page_instant_view_database_key(web_page_id), Auto());
@ -594,7 +594,7 @@ void WebPagesManager::update_web_page_instant_view(WebPageId web_page_id, WebPag
if (new_instant_view.is_empty && !new_from_database) { if (new_instant_view.is_empty && !new_from_database) {
// new_instant_view is from server and is empty, need to delete the instant view // new_instant_view is from server and is empty, need to delete the instant view
if (G()->parameters().use_message_db && (!old_instant_view.is_empty || !old_from_database)) { if (G()->use_message_database() && (!old_instant_view.is_empty || !old_from_database)) {
// we have no instant view and probably want it to be deleted from database // we have no instant view and probably want it to be deleted from database
LOG(INFO) << "Erase instant view of " << web_page_id << " from database"; LOG(INFO) << "Erase instant view of " << web_page_id << " from database";
new_instant_view.was_loaded_from_database = true; new_instant_view.was_loaded_from_database = true;
@ -607,7 +607,7 @@ void WebPagesManager::update_web_page_instant_view(WebPageId web_page_id, WebPag
new_instant_view = std::move(old_instant_view); new_instant_view = std::move(old_instant_view);
} }
if (G()->parameters().use_message_db && !new_instant_view.is_empty && new_instant_view.is_loaded) { if (G()->use_message_database() && !new_instant_view.is_empty && new_instant_view.is_loaded) {
// we have instant view and probably want it to be saved // we have instant view and probably want it to be saved
if (!new_from_database && !old_from_database) { if (!new_from_database && !old_from_database) {
// if it wasn't loaded from the database, load it first // if it wasn't loaded from the database, load it first
@ -674,7 +674,7 @@ void WebPagesManager::on_get_web_page_instant_view_view_count(WebPageId web_page
return; return;
} }
instant_view->view_count = view_count; instant_view->view_count = view_count;
if (G()->parameters().use_message_db) { if (G()->use_message_database()) {
LOG(INFO) << "Save instant view of " << web_page_id << " to database after updating view count to " << view_count; LOG(INFO) << "Save instant view of " << web_page_id << " to database after updating view count to " << view_count;
G()->td_db()->get_sqlite_pmc()->set(get_web_page_instant_view_database_key(web_page_id), G()->td_db()->get_sqlite_pmc()->set(get_web_page_instant_view_database_key(web_page_id),
log_event_store(*instant_view).as_slice().str(), Auto()); log_event_store(*instant_view).as_slice().str(), Auto());
@ -683,7 +683,7 @@ void WebPagesManager::on_get_web_page_instant_view_view_count(WebPageId web_page
void WebPagesManager::on_get_web_page_by_url(const string &url, WebPageId web_page_id, bool from_database) { void WebPagesManager::on_get_web_page_by_url(const string &url, WebPageId web_page_id, bool from_database) {
auto &cached_web_page_id = url_to_web_page_id_[url]; auto &cached_web_page_id = url_to_web_page_id_[url];
if (!from_database && G()->parameters().use_message_db) { if (!from_database && G()->use_message_database()) {
if (web_page_id.is_valid()) { if (web_page_id.is_valid()) {
if (cached_web_page_id != web_page_id) { // not already saved if (cached_web_page_id != web_page_id) { // not already saved
G()->td_db()->get_sqlite_pmc()->set(get_web_page_url_database_key(url), to_string(web_page_id.get()), Auto()); G()->td_db()->get_sqlite_pmc()->set(get_web_page_url_database_key(url), to_string(web_page_id.get()), Auto());
@ -859,7 +859,7 @@ void WebPagesManager::load_web_page_instant_view(WebPageId web_page_id, bool for
const WebPageInstantView *web_page_instant_view = get_web_page_instant_view(web_page_id); const WebPageInstantView *web_page_instant_view = get_web_page_instant_view(web_page_id);
CHECK(web_page_instant_view != nullptr); CHECK(web_page_instant_view != nullptr);
if (G()->parameters().use_message_db && !web_page_instant_view->was_loaded_from_database) { if (G()->use_message_database() && !web_page_instant_view->was_loaded_from_database) {
LOG(INFO) << "Trying to load " << web_page_id << " instant view from database"; LOG(INFO) << "Trying to load " << web_page_id << " instant view from database";
G()->td_db()->get_sqlite_pmc()->get( G()->td_db()->get_sqlite_pmc()->get(
get_web_page_instant_view_database_key(web_page_id), get_web_page_instant_view_database_key(web_page_id),
@ -894,7 +894,7 @@ void WebPagesManager::on_load_web_page_instant_view_from_database(WebPageId web_
if (G()->close_flag()) { if (G()->close_flag()) {
return; return;
} }
CHECK(G()->parameters().use_message_db); CHECK(G()->use_message_database());
LOG(INFO) << "Successfully loaded " << web_page_id << " instant view of size " << value.size() << " from database"; LOG(INFO) << "Successfully loaded " << web_page_id << " instant view of size " << value.size() << " from database";
// G()->td_db()->get_sqlite_pmc()->erase(get_web_page_instant_view_database_key(web_page_id), Auto()); // G()->td_db()->get_sqlite_pmc()->erase(get_web_page_instant_view_database_key(web_page_id), Auto());
// value.clear(); // value.clear();
@ -1035,7 +1035,7 @@ void WebPagesManager::load_web_page_by_url(string url, Promise<WebPageId> &&prom
if (url.empty()) { if (url.empty()) {
return promise.set_value(WebPageId()); return promise.set_value(WebPageId());
} }
if (!G()->parameters().use_message_db) { if (!G()->use_message_database()) {
return reload_web_page_by_url(url, std::move(promise)); return reload_web_page_by_url(url, std::move(promise));
} }
@ -1490,7 +1490,7 @@ class WebPagesManager::WebPageLogEvent {
}; };
void WebPagesManager::save_web_page(const WebPage *web_page, WebPageId web_page_id, bool from_binlog) { void WebPagesManager::save_web_page(const WebPage *web_page, WebPageId web_page_id, bool from_binlog) {
if (!G()->parameters().use_message_db) { if (!G()->use_message_database()) {
return; return;
} }
@ -1518,7 +1518,7 @@ string WebPagesManager::get_web_page_url_database_key(const string &url) {
} }
void WebPagesManager::on_binlog_web_page_event(BinlogEvent &&event) { void WebPagesManager::on_binlog_web_page_event(BinlogEvent &&event) {
if (!G()->parameters().use_message_db) { if (!G()->use_message_database()) {
binlog_erase(G()->td_db()->get_binlog(), event.id_); binlog_erase(G()->td_db()->get_binlog(), event.id_);
return; return;
} }
@ -1568,8 +1568,7 @@ void WebPagesManager::on_save_web_page_to_database(WebPageId web_page_id, bool s
} }
void WebPagesManager::load_web_page_from_database(WebPageId web_page_id, Promise<Unit> promise) { void WebPagesManager::load_web_page_from_database(WebPageId web_page_id, Promise<Unit> promise) {
if (!G()->parameters().use_message_db || loaded_from_database_web_pages_.count(web_page_id) || if (!G()->use_message_database() || loaded_from_database_web_pages_.count(web_page_id) || !web_page_id.is_valid()) {
!web_page_id.is_valid()) {
promise.set_value(Unit()); promise.set_value(Unit());
return; return;
} }
@ -1634,7 +1633,7 @@ const WebPagesManager::WebPage *WebPagesManager::get_web_page_force(WebPageId we
if (web_page != nullptr) { if (web_page != nullptr) {
return web_page; return web_page;
} }
if (!G()->parameters().use_message_db) { if (!G()->use_message_database()) {
return nullptr; return nullptr;
} }
if (!web_page_id.is_valid() || loaded_from_database_web_pages_.count(web_page_id)) { if (!web_page_id.is_valid() || loaded_from_database_web_pages_.count(web_page_id)) {

View File

@ -38,7 +38,7 @@ void FileGcWorker::run_gc(const FileGcParameters &parameters, std::vector<FullFi
std::array<bool, MAX_FILE_TYPE> immune_types{{false}}; std::array<bool, MAX_FILE_TYPE> immune_types{{false}};
if (G()->parameters().use_file_db) { if (G()->use_file_database()) {
// immune by default // immune by default
immune_types[narrow_cast<size_t>(FileType::Sticker)] = true; immune_types[narrow_cast<size_t>(FileType::Sticker)] = true;
immune_types[narrow_cast<size_t>(FileType::ProfilePhoto)] = true; immune_types[narrow_cast<size_t>(FileType::ProfilePhoto)] = true;
@ -61,7 +61,7 @@ void FileGcWorker::run_gc(const FileGcParameters &parameters, std::vector<FullFi
} }
} }
if (G()->parameters().use_file_db) { if (G()->use_file_database()) {
immune_types[narrow_cast<size_t>(FileType::EncryptedThumbnail)] = true; immune_types[narrow_cast<size_t>(FileType::EncryptedThumbnail)] = true;
} }

View File

@ -25,7 +25,7 @@ FileLoadManager::FileLoadManager(ActorShared<Callback> callback, ActorShared<> p
void FileLoadManager::start_up() { void FileLoadManager::start_up() {
constexpr int64 MAX_UPLOAD_RESOURCE_LIMIT = 4 << 20; constexpr int64 MAX_UPLOAD_RESOURCE_LIMIT = 4 << 20;
upload_resource_manager_ = create_actor<ResourceManager>("UploadResourceManager", MAX_UPLOAD_RESOURCE_LIMIT, upload_resource_manager_ = create_actor<ResourceManager>("UploadResourceManager", MAX_UPLOAD_RESOURCE_LIMIT,
!G()->parameters().use_file_db /*tdlib_engine*/ !G()->use_file_database() /*tdlib_engine*/
? ResourceManager::Mode::Greedy ? ResourceManager::Mode::Greedy
: ResourceManager::Mode::Baseline); : ResourceManager::Mode::Baseline);
if (G()->get_option_boolean("is_premium")) { if (G()->get_option_boolean("is_premium")) {

View File

@ -821,7 +821,7 @@ void prepare_path_for_pmc(FileType file_type, string &path) {
} // namespace } // namespace
FileManager::FileManager(unique_ptr<Context> context) : context_(std::move(context)) { FileManager::FileManager(unique_ptr<Context> context) : context_(std::move(context)) {
if (G()->parameters().use_file_db) { if (G()->use_file_database()) {
file_db_ = G()->td_db()->get_file_db_shared(); file_db_ = G()->td_db()->get_file_db_shared();
} }

View File

@ -146,7 +146,7 @@ void scan_fs(CancellationToken &token, CallbackT &&callback) {
} // namespace } // namespace
void FileStatsWorker::get_stats(bool need_all_files, bool split_by_owner_dialog_id, Promise<FileStats> promise) { void FileStatsWorker::get_stats(bool need_all_files, bool split_by_owner_dialog_id, Promise<FileStats> promise) {
if (!G()->parameters().use_chat_info_db) { if (!G()->use_chat_info_database()) {
split_by_owner_dialog_id = false; split_by_owner_dialog_id = false;
} }
if (!split_by_owner_dialog_id) { if (!split_by_owner_dialog_id) {