diff --git a/td/telegram/files/FileManager.cpp b/td/telegram/files/FileManager.cpp index c282c58c..83eba2c1 100644 --- a/td/telegram/files/FileManager.cpp +++ b/td/telegram/files/FileManager.cpp @@ -3577,34 +3577,26 @@ void FileManager::memory_cleanup() { /* DESTROY INVALID file_hash_to_file_id_ */ for (const auto &pair : file_hash_to_file_id_) { - if (pair.second.fast_get() != 0) { - auto &file = file_id_info_[pair.second.fast_get()]; + auto &file = file_id_info_[pair.second.fast_get()]; - if (file.node_id_ == 0) { - file_hash_to_file_id_.erase(pair.first); - } + if (file_nodes_[file.node_id_] == nullptr) { + file_hash_to_file_id_.erase(pair.first); } } /* DESTROY INVALID local_location_to_file_id_ */ for (const auto &pair : local_location_to_file_id_) { - if (pair.second.fast_get() != 0) { - auto &file = file_id_info_[pair.second.fast_get()]; - - if (file.node_id_ == 0) { - local_location_to_file_id_.erase(pair.first); - } + auto &file = file_id_info_[pair.second.fast_get()]; + if (file_nodes_[file.node_id_] == nullptr) { + local_location_to_file_id_.erase(pair.first); } } /* DESTROY INVALID generate_location_to_file_id_ */ for (const auto &pair : generate_location_to_file_id_) { - if (pair.second.fast_get() != 0) { - auto &file = file_id_info_[pair.second.fast_get()]; - - if (file.node_id_ == 0) { - generate_location_to_file_id_.erase(pair.first); - } + auto &file = file_id_info_[pair.second.fast_get()]; + if (file_nodes_[file.node_id_] == nullptr) { + generate_location_to_file_id_.erase(pair.first); } }