diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 54b30d25d..142af97df 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -21559,6 +21559,11 @@ Status MessagesManager::view_messages(DialogId dialog_id, MessageId top_thread_m view_id = ++info->current_view_id; info->recently_viewed_messages[view_id] = message_id; } + + auto file_ids = get_message_content_file_ids(m->content.get(), td_); + for (auto file_id : file_ids) { + td_->file_manager_->check_local_location_async(file_id, true); + } } else if (!message_id.is_yet_unsent() && message_id > max_message_id) { if (message_id <= d->max_notification_message_id || message_id <= d->last_new_message_id || message_id <= max_thread_message_id) { @@ -21719,6 +21724,11 @@ Status MessagesManager::open_message_content(FullMessageId full_message_id) { on_message_live_location_viewed(d, m); } + auto file_ids = get_message_content_file_ids(m->content.get(), td_); + for (auto file_id : file_ids) { + td_->file_manager_->check_local_location_async(file_id, true); + } + return Status::OK(); } diff --git a/td/telegram/files/FileManager.cpp b/td/telegram/files/FileManager.cpp index 099ef92c2..71531de0c 100644 --- a/td/telegram/files/FileManager.cpp +++ b/td/telegram/files/FileManager.cpp @@ -928,6 +928,13 @@ void FileManager::check_local_location(FileId file_id, bool skip_file_size_check } } +void FileManager::check_local_location_async(FileId file_id, bool skip_file_size_checks) { + auto node = get_sync_file_node(file_id); + if (node) { + check_local_location_async(node, skip_file_size_checks, Promise()); + } +} + Status FileManager::check_local_location(FileNodePtr node, bool skip_file_size_checks) { Status status; if (node->local_.type() == LocalFileLocation::Type::Full) { diff --git a/td/telegram/files/FileManager.h b/td/telegram/files/FileManager.h index e1f8d1a0d..cf5d549c8 100644 --- a/td/telegram/files/FileManager.h +++ b/td/telegram/files/FileManager.h @@ -452,6 +452,7 @@ class FileManager final : public FileLoadManager::Callback { bool set_content(FileId file_id, BufferSlice bytes); void check_local_location(FileId file_id, bool skip_file_size_checks); + void check_local_location_async(FileId file_id, bool skip_file_size_checks); void download(FileId file_id, std::shared_ptr callback, int32 new_priority, int64 offset, int64 limit, Promise> promise);