Ignore SQLite key-value responses after close.

GitOrigin-RevId: a91a2dbbf8efcda91959aabfcaca964caa6fe3c3
This commit is contained in:
levlam 2020-05-16 02:25:03 +03:00
parent 44a2a65600
commit b29a945b1a
7 changed files with 87 additions and 1 deletions

View File

@ -501,6 +501,9 @@ void AnimationsManager::load_saved_animations(Promise<Unit> &&promise) {
}
void AnimationsManager::on_load_saved_animations_from_database(const string &value) {
if (G()->close_flag()) {
return;
}
if (value.empty()) {
LOG(INFO) << "Saved animations aren't found in database";
reload_saved_animations(true);

View File

@ -473,6 +473,10 @@ BackgroundId BackgroundManager::search_background(const string &name, Promise<Un
}
void BackgroundManager::on_load_background_from_database(string name, string value) {
if (G()->close_flag()) {
return;
}
auto promises_it = being_loaded_from_database_backgrounds_.find(name);
CHECK(promises_it != being_loaded_from_database_backgrounds_.end());
auto promises = std::move(promises_it->second);

View File

@ -4718,6 +4718,10 @@ void ContactsManager::load_imported_contacts(Promise<Unit> &&promise) {
}
void ContactsManager::on_load_imported_contacts_from_database(string value) {
if (G()->close_flag()) {
return;
}
CHECK(!are_imported_contacts_loaded_);
if (need_clear_imported_contacts_) {
need_clear_imported_contacts_ = false;
@ -6673,6 +6677,9 @@ void ContactsManager::on_deleted_contacts(const vector<UserId> &deleted_contact_
}
void ContactsManager::save_next_contacts_sync_date() {
if (G()->close_flag()) {
return;
}
if (!G()->parameters().use_chat_info_db) {
return;
}
@ -6769,6 +6776,9 @@ void ContactsManager::on_get_contacts_failed(Status error) {
}
void ContactsManager::on_load_contacts_from_database(string value) {
if (G()->close_flag()) {
return;
}
if (value.empty()) {
reload_contacts(true);
return;
@ -7161,6 +7171,10 @@ void ContactsManager::save_user_to_database_impl(User *u, UserId user_id, string
}
void ContactsManager::on_save_user_to_database(UserId user_id, bool success) {
if (G()->close_flag()) {
return;
}
User *u = get_user(user_id);
CHECK(u != nullptr);
LOG_CHECK(u->is_being_saved) << user_id << " " << u->is_saved << " " << u->is_status_saved << " "
@ -7213,6 +7227,10 @@ void ContactsManager::load_user_from_database_impl(UserId user_id, Promise<Unit>
}
void ContactsManager::on_load_user_from_database(UserId user_id, string value) {
if (G()->close_flag()) {
return;
}
if (!loaded_from_database_users_.insert(user_id).second) {
return;
}
@ -7427,6 +7445,10 @@ void ContactsManager::save_chat_to_database_impl(Chat *c, ChatId chat_id, string
}
void ContactsManager::on_save_chat_to_database(ChatId chat_id, bool success) {
if (G()->close_flag()) {
return;
}
Chat *c = get_chat(chat_id);
CHECK(c != nullptr);
CHECK(c->is_being_saved);
@ -7473,6 +7495,10 @@ void ContactsManager::load_chat_from_database_impl(ChatId chat_id, Promise<Unit>
}
void ContactsManager::on_load_chat_from_database(ChatId chat_id, string value) {
if (G()->close_flag()) {
return;
}
if (!loaded_from_database_chats_.insert(chat_id).second) {
return;
}
@ -7656,6 +7682,10 @@ void ContactsManager::save_channel_to_database_impl(Channel *c, ChannelId channe
}
void ContactsManager::on_save_channel_to_database(ChannelId channel_id, bool success) {
if (G()->close_flag()) {
return;
}
Channel *c = get_channel(channel_id);
CHECK(c != nullptr);
CHECK(c->is_being_saved);
@ -7702,6 +7732,10 @@ void ContactsManager::load_channel_from_database_impl(ChannelId channel_id, Prom
}
void ContactsManager::on_load_channel_from_database(ChannelId channel_id, string value) {
if (G()->close_flag()) {
return;
}
if (!loaded_from_database_channels_.insert(channel_id).second) {
return;
}
@ -7888,6 +7922,10 @@ void ContactsManager::save_secret_chat_to_database_impl(SecretChat *c, SecretCha
}
void ContactsManager::on_save_secret_chat_to_database(SecretChatId secret_chat_id, bool success) {
if (G()->close_flag()) {
return;
}
SecretChat *c = get_secret_chat(secret_chat_id);
CHECK(c != nullptr);
CHECK(c->is_being_saved);
@ -7935,6 +7973,10 @@ void ContactsManager::load_secret_chat_from_database_impl(SecretChatId secret_ch
}
void ContactsManager::on_load_secret_chat_from_database(SecretChatId secret_chat_id, string value) {
if (G()->close_flag()) {
return;
}
if (!loaded_from_database_secret_chats_.insert(secret_chat_id).second) {
return;
}
@ -12728,7 +12770,7 @@ void ContactsManager::load_dialog_administrators(DialogId dialog_id, Promise<Uni
void ContactsManager::on_load_dialog_administrators_from_database(DialogId dialog_id, string value,
Promise<Unit> &&promise) {
if (value.empty()) {
if (value.empty() || G()->close_flag()) {
promise.set_value(Unit());
return;
}

View File

@ -86,6 +86,10 @@ void HashtagHints::hashtag_used_impl(const string &hashtag) {
}
void HashtagHints::from_db(Result<string> data, bool dummy) {
if (G()->close_flag()) {
return;
}
sync_with_db_ = true;
if (data.is_error() || data.ok().empty()) {
return;

View File

@ -16588,6 +16588,9 @@ vector<FullMessageId> MessagesManager::get_active_live_location_messages(Promise
}
void MessagesManager::on_load_active_live_location_full_message_ids_from_database(string value) {
if (G()->close_flag()) {
return;
}
if (value.empty()) {
LOG(INFO) << "Active live location messages aren't found in the database";
on_load_active_live_location_messages_finished();

View File

@ -3060,6 +3060,9 @@ void StickersManager::load_installed_sticker_sets(bool is_masks, Promise<Unit> &
}
void StickersManager::on_load_installed_sticker_sets_from_database(bool is_masks, string value) {
if (G()->close_flag()) {
return;
}
if (value.empty()) {
LOG(INFO) << "Installed " << (is_masks ? "mask " : "") << "sticker sets aren't found in database";
reload_installed_sticker_sets(is_masks, true);
@ -3266,6 +3269,9 @@ void StickersManager::load_sticker_sets_without_stickers(vector<StickerSetId> &&
}
void StickersManager::on_load_sticker_set_from_database(StickerSetId sticker_set_id, bool with_stickers, string value) {
if (G()->close_flag()) {
return;
}
StickerSet *sticker_set = get_sticker_set(sticker_set_id);
CHECK(sticker_set != nullptr);
if (sticker_set->was_loaded) {
@ -3852,6 +3858,9 @@ void StickersManager::load_featured_sticker_sets(Promise<Unit> &&promise) {
}
void StickersManager::on_load_featured_sticker_sets_from_database(string value) {
if (G()->close_flag()) {
return;
}
if (value.empty()) {
LOG(INFO) << "Trending sticker sets aren't found in database";
reload_featured_sticker_sets(true);
@ -3928,6 +3937,9 @@ void StickersManager::load_old_featured_sticker_sets(Promise<Unit> &&promise) {
}
void StickersManager::on_load_old_featured_sticker_sets_from_database(uint32 generation, string value) {
if (G()->close_flag()) {
return;
}
if (generation != old_featured_sticker_set_generation_) {
return;
}
@ -4914,6 +4926,9 @@ void StickersManager::load_recent_stickers(bool is_attached, Promise<Unit> &&pro
}
void StickersManager::on_load_recent_stickers_from_database(bool is_attached, string value) {
if (G()->close_flag()) {
return;
}
if (value.empty()) {
LOG(INFO) << "Recent " << (is_attached ? "attached " : "") << "stickers aren't found in database";
reload_recent_stickers(is_attached, true);
@ -5332,6 +5347,9 @@ void StickersManager::load_favorite_stickers(Promise<Unit> &&promise) {
}
void StickersManager::on_load_favorite_stickers_from_database(const string &value) {
if (G()->close_flag()) {
return;
}
if (value.empty()) {
LOG(INFO) << "Favorite stickers aren't found in database";
reload_favorite_stickers(true);

View File

@ -919,6 +919,9 @@ void WebPagesManager::reload_web_page_instant_view(WebPageId web_page_id) {
}
void WebPagesManager::on_load_web_page_instant_view_from_database(WebPageId web_page_id, string value) {
if (G()->close_flag()) {
return;
}
CHECK(G()->parameters().use_message_db);
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());
@ -1072,6 +1075,9 @@ void WebPagesManager::load_web_page_by_url(const string &url, Promise<Unit> &&pr
void WebPagesManager::on_load_web_page_id_by_url_from_database(const string &url, string value,
Promise<Unit> &&promise) {
if (G()->close_flag()) {
return;
}
LOG(INFO) << "Successfully loaded url \"" << url << "\" of size " << value.size() << " from database";
// G()->td_db()->get_sqlite_pmc()->erase(get_web_page_url_database_key(web_page_id), Auto());
// return;
@ -1545,6 +1551,9 @@ string WebPagesManager::get_web_page_database_key(WebPageId web_page_id) {
}
void WebPagesManager::on_save_web_page_to_database(WebPageId web_page_id, bool success) {
if (G()->close_flag()) {
return;
}
const WebPage *web_page = get_web_page(web_page_id);
if (web_page == nullptr) {
LOG(ERROR) << "Can't find " << (success ? "saved " : "failed to save ") << web_page_id;
@ -1583,6 +1592,9 @@ void WebPagesManager::load_web_page_from_database(WebPageId web_page_id, Promise
}
void WebPagesManager::on_load_web_page_from_database(WebPageId web_page_id, string value) {
if (G()->close_flag()) {
return;
}
if (!loaded_from_database_web_pages_.insert(web_page_id).second) {
return;
}