Asynchronously check local location of all viewed and opened files.

This commit is contained in:
levlam 2023-01-25 19:25:04 +03:00
parent 5a6fb91bd9
commit 5cd523408d
3 changed files with 18 additions and 0 deletions

View File

@ -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();
}

View File

@ -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<Unit>());
}
}
Status FileManager::check_local_location(FileNodePtr node, bool skip_file_size_checks) {
Status status;
if (node->local_.type() == LocalFileLocation::Type::Full) {

View File

@ -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<DownloadCallback> callback, int32 new_priority, int64 offset,
int64 limit, Promise<td_api::object_ptr<td_api::file>> promise);