Add ignore_background_updates option.
GitOrigin-RevId: cefa2fd658d1e0426bd319db2f033b0506e0f8de
This commit is contained in:
parent
37e7543900
commit
e47f1d6947
@ -115,6 +115,11 @@ DcId Global::get_webfile_dc_id() const {
|
||||
return DcId::internal(dc_id);
|
||||
}
|
||||
|
||||
bool Global::ignore_backgrond_updates() const {
|
||||
return !parameters_.use_file_db && !parameters_.use_secret_chats &&
|
||||
shared_config_->get_option_boolean("ignore_background_updates");
|
||||
}
|
||||
|
||||
void Global::set_net_query_dispatcher(unique_ptr<NetQueryDispatcher> net_query_dispatcher) {
|
||||
net_query_dispatcher_ = std::move(net_query_dispatcher);
|
||||
}
|
||||
|
@ -88,6 +88,8 @@ class Global : public ActorContext {
|
||||
return parameters_.use_test_dc;
|
||||
}
|
||||
|
||||
bool ignore_backgrond_updates() const;
|
||||
|
||||
NetQueryCreator &net_query_creator() {
|
||||
return net_query_creator_.get();
|
||||
}
|
||||
|
@ -24597,6 +24597,10 @@ string MessagesManager::get_channel_pts_key(DialogId dialog_id) {
|
||||
}
|
||||
|
||||
int32 MessagesManager::load_channel_pts(DialogId dialog_id) const {
|
||||
if (G()->ignore_backgrond_updates()) {
|
||||
G()->td_db()->get_binlog_pmc()->erase(get_channel_pts_key(dialog_id)); // just in case
|
||||
return 0;
|
||||
}
|
||||
auto pts = to_integer<int32>(G()->td_db()->get_binlog_pmc()->get(get_channel_pts_key(dialog_id)));
|
||||
LOG(INFO) << "Load " << dialog_id << " pts = " << pts;
|
||||
return pts;
|
||||
@ -24628,7 +24632,9 @@ void MessagesManager::set_channel_pts(Dialog *d, int32 new_pts, const char *sour
|
||||
}
|
||||
|
||||
d->pts = new_pts;
|
||||
G()->td_db()->get_binlog_pmc()->set(get_channel_pts_key(d->dialog_id), to_string(new_pts));
|
||||
if (!G()->ignore_backgrond_updates()) {
|
||||
G()->td_db()->get_binlog_pmc()->set(get_channel_pts_key(d->dialog_id), to_string(new_pts));
|
||||
}
|
||||
} else if (new_pts < d->pts) {
|
||||
LOG(ERROR) << "Receive wrong pts " << new_pts << " in " << d->dialog_id << " . Current pts is " << d->pts;
|
||||
}
|
||||
|
@ -6537,6 +6537,9 @@ void Td::on_request(uint64 id, td_api::setOption &request) {
|
||||
if (set_boolean_option("ignore_inline_thumbnails")) {
|
||||
return;
|
||||
}
|
||||
if (set_boolean_option("ignore_background_updates")) {
|
||||
return;
|
||||
}
|
||||
if (set_boolean_option("is_emulator")) {
|
||||
return;
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ void UpdatesManager::on_pts_ack(PtsManager::PtsId ack_token) {
|
||||
void UpdatesManager::save_pts(int32 pts) {
|
||||
if (pts == std::numeric_limits<int32>::max()) {
|
||||
G()->td_db()->get_binlog_pmc()->erase("updates.pts");
|
||||
} else {
|
||||
} else if (!G()->ignore_backgrond_updates()) {
|
||||
G()->td_db()->get_binlog_pmc()->set("updates.pts", to_string(pts));
|
||||
}
|
||||
}
|
||||
@ -280,7 +280,9 @@ void UpdatesManager::set_qts(int32 qts) {
|
||||
LOG(INFO) << "Update qts to " << qts;
|
||||
|
||||
qts_ = qts;
|
||||
G()->td_db()->get_binlog_pmc()->set("updates.qts", to_string(qts));
|
||||
if (!G()->ignore_backgrond_updates()) {
|
||||
G()->td_db()->get_binlog_pmc()->set("updates.qts", to_string(qts));
|
||||
}
|
||||
} else if (qts < qts_) {
|
||||
LOG(ERROR) << "Receive wrong qts = " << qts << ". Current qts = " << qts_;
|
||||
}
|
||||
@ -308,7 +310,9 @@ void UpdatesManager::set_date(int32 date, bool from_update, string date_source)
|
||||
|
||||
date_ = date;
|
||||
date_source_ = std::move(date_source);
|
||||
G()->td_db()->get_binlog_pmc()->set("updates.date", to_string(date));
|
||||
if (!G()->ignore_backgrond_updates()) {
|
||||
G()->td_db()->get_binlog_pmc()->set("updates.date", to_string(date));
|
||||
}
|
||||
} else if (date < date_) {
|
||||
if (from_update) {
|
||||
date++;
|
||||
@ -867,6 +871,12 @@ void UpdatesManager::init_state() {
|
||||
}
|
||||
|
||||
auto pmc = G()->td_db()->get_binlog_pmc();
|
||||
if (G()->ignore_backgrond_updates()) {
|
||||
// just in case
|
||||
pmc->erase("updates.pts");
|
||||
pmc->erase("updates.qts");
|
||||
pmc->erase("updates.date");
|
||||
}
|
||||
string pts_str = pmc->get("updates.pts");
|
||||
if (pts_str.empty()) {
|
||||
if (!running_get_difference_) {
|
||||
|
Reference in New Issue
Block a user