From c01dcf9a992d2fe52fe5138657ad14db7e0dfcbf Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 1 Aug 2018 17:10:07 +0300 Subject: [PATCH] Add temporary ignoring of duplicate user/channel log events. GitOrigin-RevId: ecd17421d9f2c3591ce4a4d84970949954f8496e --- td/telegram/ContactsManager.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 89dff8bf..c53da273 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -5177,7 +5177,12 @@ void ContactsManager::on_binlog_user_event(BinlogEvent &&event) { auto user_id = log_event.user_id; LOG(INFO) << "Add " << user_id << " from binlog"; User *u = add_user(user_id, "on_binlog_user_event"); - CHECK(u->first_name.empty()) << user_id << " " << u->debug_source; + if (!(u->first_name.empty() && u->last_name.empty()) && Slice(u->debug_source) == Slice("on_binlog_user_event")) { + LOG(ERROR) << "Skip adding already added " << user_id; + binlog_erase(G()->td_db()->get_binlog(), event.id_); + return; // TODO fix bug in Binlog and remove that fix + } + CHECK(u->first_name.empty() && u->last_name.empty()) << user_id << " " << u->debug_source; *u = std::move(log_event.u); // users come from binlog before all other events, so just add them u->logevent_id = event.id_; @@ -5649,6 +5654,11 @@ void ContactsManager::on_binlog_channel_event(BinlogEvent &&event) { auto channel_id = log_event.channel_id; LOG(INFO) << "Add " << channel_id << " from binlog"; Channel *c = add_channel(channel_id, "on_binlog_channel_event"); + if (!c->status.is_banned() && Slice(c->debug_source) == Slice("on_binlog_channel_event")) { + LOG(ERROR) << "Skip adding already added " << channel_id; + binlog_erase(G()->td_db()->get_binlog(), event.id_); + return; // TODO fix bug in Binlog and remove that fix + } CHECK(c->status.is_banned()) << channel_id << " " << c->debug_source; *c = std::move(log_event.c); // channels come from binlog before all other events, so just add them