Add and use "since_last_open" internal option.
This commit is contained in:
parent
0469ac0147
commit
47fd88b33f
@ -283,9 +283,9 @@ bool OptionManager::is_internal_option(Slice name) {
|
||||
name == "revoke_time_limit" || name == "revoke_pm_time_limit";
|
||||
case 's':
|
||||
return name == "saved_animations_limit" || name == "saved_gifs_limit_default" ||
|
||||
name == "saved_gifs_limit_premium" || name == "session_count" || name == "stickers_faved_limit_default" ||
|
||||
name == "stickers_faved_limit_premium" || name == "stickers_normal_by_emoji_per_premium_num" ||
|
||||
name == "stickers_premium_by_emoji_num";
|
||||
name == "saved_gifs_limit_premium" || name == "session_count" || name == "since_last_open" ||
|
||||
name == "stickers_faved_limit_default" || name == "stickers_faved_limit_premium" ||
|
||||
name == "stickers_normal_by_emoji_per_premium_num" || name == "stickers_premium_by_emoji_num";
|
||||
case 'v':
|
||||
return name == "video_note_size_max";
|
||||
case 'w':
|
||||
|
@ -3580,14 +3580,22 @@ void Td::init(Result<TdDb::OpenedDatabase> r_opened_database) {
|
||||
}
|
||||
});
|
||||
|
||||
options_.language_pack = G()->get_option_string("localization_target");
|
||||
options_.language_code = G()->get_option_string("language_pack_id");
|
||||
options_.parameters = G()->get_option_string("connection_parameters");
|
||||
options_.tz_offset = static_cast<int32>(G()->get_option_integer("utc_time_offset"));
|
||||
options_.is_emulator = G()->get_option_boolean("is_emulator");
|
||||
if (events.since_last_open >= 3600) {
|
||||
auto old_since_last_open = option_manager_->get_option_integer("since_last_open");
|
||||
if (events.since_last_open > old_since_last_open) {
|
||||
option_manager_->set_option_integer("since_last_open", events.since_last_open);
|
||||
}
|
||||
}
|
||||
|
||||
options_.language_pack = option_manager_->get_option_string("localization_target");
|
||||
options_.language_code = option_manager_->get_option_string("language_pack_id");
|
||||
options_.parameters = option_manager_->get_option_string("connection_parameters");
|
||||
options_.tz_offset = static_cast<int32>(option_manager_->get_option_integer("utc_time_offset"));
|
||||
options_.is_emulator = option_manager_->get_option_boolean("is_emulator");
|
||||
// options_.proxy = Proxy();
|
||||
G()->set_mtproto_header(make_unique<MtprotoHeader>(options_));
|
||||
G()->set_store_all_files_in_files_directory(G()->get_option_boolean("store_all_files_in_files_directory"));
|
||||
G()->set_store_all_files_in_files_directory(
|
||||
option_manager_->get_option_boolean("store_all_files_in_files_directory"));
|
||||
|
||||
VLOG(td_init) << "Create NetQueryDispatcher";
|
||||
auto net_query_dispatcher = make_unique<NetQueryDispatcher>([&] { return create_reference(); });
|
||||
|
@ -63,6 +63,9 @@ Status init_binlog(Binlog &binlog, string path, BinlogKeyValue<Binlog> &binlog_p
|
||||
if (since_last_open >= 86400) {
|
||||
LOG(WARNING) << "Binlog wasn't opened for " << since_last_open << " seconds";
|
||||
}
|
||||
if (since_last_open > 0 && since_last_open < 1e12) {
|
||||
events.since_last_open = static_cast<int64>(since_last_open);
|
||||
}
|
||||
}
|
||||
|
||||
auto callback = [&](const BinlogEvent &event) {
|
||||
|
@ -67,6 +67,8 @@ class TdDb {
|
||||
vector<BinlogEvent> to_messages_manager;
|
||||
vector<BinlogEvent> to_notification_manager;
|
||||
vector<BinlogEvent> to_notification_settings_manager;
|
||||
|
||||
int64 since_last_open = 0;
|
||||
};
|
||||
static void open(int32 scheduler_id, TdParameters parameters, DbKey key, Promise<OpenedDatabase> &&promise);
|
||||
|
||||
|
@ -183,6 +183,10 @@ UpdatesManager::UpdatesManager(Td *td, ActorShared<> parent) : td_(td), parent_(
|
||||
|
||||
pending_audio_transcription_timeout_.set_callback(on_pending_audio_transcription_timeout_callback);
|
||||
pending_audio_transcription_timeout_.set_callback_data(static_cast<void *>(td_));
|
||||
|
||||
if (td_->option_manager_->get_option_integer("since_last_open") < 3600) {
|
||||
finished_first_get_difference_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
void UpdatesManager::tear_down() {
|
||||
@ -1463,8 +1467,12 @@ void UpdatesManager::init_state() {
|
||||
return;
|
||||
}
|
||||
|
||||
bool drop_state = !G()->parameters().use_file_db && !G()->parameters().use_secret_chats &&
|
||||
td_->auth_manager_->is_bot() &&
|
||||
td_->option_manager_->get_option_integer("since_last_open") >= 2 * 86400;
|
||||
|
||||
auto pmc = G()->td_db()->get_binlog_pmc();
|
||||
if (G()->ignore_background_updates()) {
|
||||
if (G()->ignore_background_updates() || drop_state) {
|
||||
// just in case
|
||||
pmc->erase("updates.pts");
|
||||
pmc->erase("updates.qts");
|
||||
@ -1755,6 +1763,7 @@ void UpdatesManager::after_get_difference() {
|
||||
retry_time_ = 1;
|
||||
|
||||
finished_first_get_difference_ = true;
|
||||
td_->option_manager_->set_option_empty("since_last_open");
|
||||
|
||||
// cancels qts_gap_timeout_ if needed, can apply some updates received during getDifference,
|
||||
// but missed in getDifference
|
||||
|
Loading…
x
Reference in New Issue
Block a user