Fix data ttl
This commit is contained in:
parent
f9c9f2bd59
commit
6babc009d7
@ -14533,6 +14533,8 @@ void ContactsManager::get_current_state(vector<td_api::object_ptr<td_api::Update
|
|||||||
void ContactsManager::memory_cleanup() {
|
void ContactsManager::memory_cleanup() {
|
||||||
std::lock_guard<std::shared_timed_mutex> writerLock(memory_cleanup_mutex);
|
std::lock_guard<std::shared_timed_mutex> writerLock(memory_cleanup_mutex);
|
||||||
|
|
||||||
|
auto time = std::time(nullptr);
|
||||||
|
|
||||||
auto user_ttl = !G()->shared_config().get_option_integer("delete_user_reference_after_seconds", 3600);
|
auto user_ttl = !G()->shared_config().get_option_integer("delete_user_reference_after_seconds", 3600);
|
||||||
auto chat_ttl = !G()->shared_config().get_option_integer("delete_chat_reference_after_seconds", 3600);
|
auto chat_ttl = !G()->shared_config().get_option_integer("delete_chat_reference_after_seconds", 3600);
|
||||||
|
|
||||||
@ -14543,7 +14545,7 @@ void ContactsManager::memory_cleanup() {
|
|||||||
//auto &user = it->second;
|
//auto &user = it->second;
|
||||||
auto user_id = it->first;
|
auto user_id = it->first;
|
||||||
|
|
||||||
auto is_invalid = user_id.get_time() > user_ttl;
|
auto is_invalid = time - user_id.get_time() > user_ttl || user_id.get_time() > time;
|
||||||
|
|
||||||
if (is_invalid) {
|
if (is_invalid) {
|
||||||
user_id.reset_time();
|
user_id.reset_time();
|
||||||
@ -14576,7 +14578,7 @@ void ContactsManager::memory_cleanup() {
|
|||||||
//auto &chat = it->second;
|
//auto &chat = it->second;
|
||||||
auto chat_id = it->first;
|
auto chat_id = it->first;
|
||||||
|
|
||||||
auto is_invalid = chat_id.get_time() > chat_ttl;
|
auto is_invalid = time - chat_id.get_time() > chat_ttl || chat_id.get_time() > time;
|
||||||
|
|
||||||
if (is_invalid) {
|
if (is_invalid) {
|
||||||
chat_id.reset_time();
|
chat_id.reset_time();
|
||||||
@ -14604,7 +14606,7 @@ void ContactsManager::memory_cleanup() {
|
|||||||
//auto &channel = it->second;
|
//auto &channel = it->second;
|
||||||
auto channel_id = it->first;
|
auto channel_id = it->first;
|
||||||
|
|
||||||
auto is_invalid = channel_id.get_time() > chat_ttl;
|
auto is_invalid = time - channel_id.get_time() > chat_ttl || channel_id.get_time() > time;
|
||||||
|
|
||||||
if (is_invalid) {
|
if (is_invalid) {
|
||||||
channel_id.reset_time();
|
channel_id.reset_time();
|
||||||
|
@ -3882,7 +3882,7 @@ void FileManager::memory_cleanup() {
|
|||||||
if (find_node != file_nodes_.end()) {
|
if (find_node != file_nodes_.end()) {
|
||||||
auto &node = find_node->second;
|
auto &node = find_node->second;
|
||||||
|
|
||||||
if (time - node->main_file_id_.get_time() > file_ttl) {
|
if (time - node->main_file_id_.get_time() > file_ttl || node->main_file_id_.get_time() > time) {
|
||||||
auto can_reset = node->download_priority_ == 0;
|
auto can_reset = node->download_priority_ == 0;
|
||||||
can_reset &= node->generate_download_priority_ == 0;
|
can_reset &= node->generate_download_priority_ == 0;
|
||||||
can_reset &= node->download_id_ == 0;
|
can_reset &= node->download_id_ == 0;
|
||||||
@ -3895,7 +3895,7 @@ void FileManager::memory_cleanup() {
|
|||||||
if (find_file != file_id_info_.end()) {
|
if (find_file != file_id_info_.end()) {
|
||||||
auto &file = find_file->second;
|
auto &file = find_file->second;
|
||||||
can_reset &= file.download_priority_ == 0;
|
can_reset &= file.download_priority_ == 0;
|
||||||
can_reset &= time - file_ids_it->get_time() > file_ttl;
|
can_reset &= time - file_ids_it->get_time() > file_ttl || file_ids_it->get_time() > time;
|
||||||
}
|
}
|
||||||
file_ids_it++;
|
file_ids_it++;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user