From ed26d0da165e1a9674eb35a6e8f3296050ca57d8 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 26 Jun 2024 13:39:52 +0300 Subject: [PATCH] Add struct UploadedFileInfo. --- td/telegram/MessagesManager.cpp | 12 ++++++------ td/telegram/MessagesManager.h | 7 +++++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 43fa7ee57..dcfa7ec50 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -8266,8 +8266,8 @@ void MessagesManager::on_upload_media(FileId file_id, tl_object_ptrsecond.first; - auto thumbnail_file_id = it->second.second; + auto message_full_id = it->second.message_full_id; + auto thumbnail_file_id = it->second.thumbnail_file_id; being_uploaded_files_.erase(it); @@ -8395,7 +8395,7 @@ void MessagesManager::on_upload_media_error(FileId file_id, Status status) { return; } - auto message_full_id = it->second.first; + auto message_full_id = it->second.message_full_id; being_uploaded_files_.erase(it); @@ -12314,7 +12314,7 @@ void MessagesManager::hangup() { if (!G()->use_message_database()) { while (!being_uploaded_files_.empty()) { auto it = being_uploaded_files_.begin(); - auto message_full_id = it->second.first; + auto message_full_id = it->second.message_full_id; being_uploaded_files_.erase(it); if (message_full_id.get_message_id().is_yet_unsent()) { fail_send_message(message_full_id, Global::request_aborted_error()); @@ -23990,7 +23990,7 @@ void MessagesManager::do_send_message(DialogId dialog_id, const Message *m, vect CHECK(file_view.is_encrypted_secret()); bool is_inserted = being_uploaded_files_ - .emplace(file_id, std::make_pair(MessageFullId(dialog_id, m->message_id), thumbnail_file_id)) + .emplace(file_id, UploadedFileInfo{MessageFullId(dialog_id, m->message_id), thumbnail_file_id}) .second; CHECK(is_inserted); // need to call resume_upload synchronously to make upload process consistent with being_uploaded_files_ @@ -24024,7 +24024,7 @@ void MessagesManager::do_send_message(DialogId dialog_id, const Message *m, vect LOG(INFO) << "Ask to upload file " << file_id << " with bad parts " << bad_parts; bool is_inserted = being_uploaded_files_ - .emplace(file_id, std::make_pair(MessageFullId(dialog_id, m->message_id), thumbnail_file_id)) + .emplace(file_id, UploadedFileInfo{MessageFullId(dialog_id, m->message_id), thumbnail_file_id}) .second; CHECK(is_inserted); // need to call resume_upload synchronously to make upload process consistent with being_uploaded_files_ diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index c5fb1d6d3..bbe79e774 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -3164,8 +3164,11 @@ class MessagesManager final : public Actor { double last_channel_pts_jump_warning_time_ = 0; - FlatHashMap, FileIdHash> - being_uploaded_files_; // file_id -> message, thumbnail_file_id + struct UploadedFileInfo { + MessageFullId message_full_id; + FileId thumbnail_file_id; + }; + FlatHashMap being_uploaded_files_; struct UploadedThumbnailInfo { MessageFullId message_full_id; FileId file_id; // original file file_id