From af5eed2abb7ca6a265fda349046044ea309946ab Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 7 May 2020 03:43:11 +0300 Subject: [PATCH] Log before checks. GitOrigin-RevId: 16b87eb9a1d763e85007de1253ada424c566ed0e --- td/telegram/MessagesManager.cpp | 24 ++++++++++++------------ td/telegram/MessagesManager.h | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 4e3835ac..4bfc4c8c 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -7408,9 +7408,9 @@ void MessagesManager::on_upload_media(FileId file_id, tl_object_ptrfile_manager_->upload(thumbnail_file_id, upload_thumbnail_callback_, 32, m->message_id.get()); } else { do_send_media(dialog_id, m, file_id, thumbnail_file_id, std::move(input_file), nullptr); @@ -7418,10 +7418,10 @@ void MessagesManager::on_upload_media(FileId file_id, tl_object_ptr input_file) { LOG(INFO) << "File " << file_id << " has been uploaded"; - auto it = uploaded_dialog_photos_.find(file_id); - if (it == uploaded_dialog_photos_.end()) { + auto it = being_uploaded_dialog_photos_.find(file_id); + if (it == being_uploaded_dialog_photos_.end()) { // just in case, as in on_upload_media return; } @@ -7619,7 +7619,7 @@ void MessagesManager::on_upload_dialog_photo(FileId file_id, tl_object_ptr promise = std::move(it->second.promise); DialogId dialog_id = it->second.dialog_id; - uploaded_dialog_photos_.erase(it); + being_uploaded_dialog_photos_.erase(it); tl_object_ptr input_chat_photo; FileView file_view = td_->file_manager_->get_file_view(file_id); @@ -7648,15 +7648,15 @@ void MessagesManager::on_upload_dialog_photo_error(FileId file_id, Status status LOG(INFO) << "File " << file_id << " has upload error " << status; CHECK(status.is_error()); - auto it = uploaded_dialog_photos_.find(file_id); - if (it == uploaded_dialog_photos_.end()) { + auto it = being_uploaded_dialog_photos_.find(file_id); + if (it == being_uploaded_dialog_photos_.end()) { // just in case, as in on_upload_media_error return; } Promise promise = std::move(it->second.promise); - uploaded_dialog_photos_.erase(it); + being_uploaded_dialog_photos_.erase(it); promise.set_error(std::move(status)); } @@ -18827,11 +18827,11 @@ void MessagesManager::do_send_message(DialogId dialog_id, const Message *m, vect auto layer = td_->contacts_manager_->get_secret_chat_layer(dialog_id.get_secret_chat_id()); auto secret_input_media = get_secret_input_media(content, td_, nullptr, BufferSlice(), layer); if (secret_input_media.empty()) { + LOG(INFO) << "Ask to upload encrypted file " << file_id; CHECK(file_view.is_encrypted_secret()); CHECK(file_id.is_valid()); CHECK(being_uploaded_files_.find(file_id) == being_uploaded_files_.end()); being_uploaded_files_[file_id] = {FullMessageId(dialog_id, m->message_id), thumbnail_file_id}; - LOG(INFO) << "Ask to upload encrypted file " << file_id; // need to call resume_upload synchronously to make upload process consistent with being_uploaded_files_ td_->file_manager_->resume_upload(file_id, std::move(bad_parts), upload_media_callback_, 1, m->message_id.get()); } else { @@ -18847,10 +18847,10 @@ void MessagesManager::do_send_message(DialogId dialog_id, const Message *m, vect thumbnail_file_id = FileId(); } + LOG(INFO) << "Ask to upload file " << file_id << " with bad parts " << bad_parts; CHECK(file_id.is_valid()); CHECK(being_uploaded_files_.find(file_id) == being_uploaded_files_.end()); being_uploaded_files_[file_id] = {FullMessageId(dialog_id, m->message_id), thumbnail_file_id}; - LOG(INFO) << "Ask to upload file " << file_id; // need to call resume_upload synchronously to make upload process consistent with being_uploaded_files_ td_->file_manager_->resume_upload(file_id, std::move(bad_parts), upload_media_callback_, 1, m->message_id.get()); } else { @@ -25136,9 +25136,9 @@ void MessagesManager::send_edit_dialog_photo_query(DialogId dialog_id, FileId fi void MessagesManager::upload_dialog_photo(DialogId dialog_id, FileId file_id, Promise &&promise) { CHECK(file_id.is_valid()); - CHECK(uploaded_dialog_photos_.find(file_id) == uploaded_dialog_photos_.end()); - uploaded_dialog_photos_[file_id] = {std::move(promise), dialog_id}; LOG(INFO) << "Ask to upload chat photo " << file_id; + CHECK(being_uploaded_dialog_photos_.find(file_id) == being_uploaded_dialog_photos_.end()); + being_uploaded_dialog_photos_[file_id] = {std::move(promise), dialog_id}; td_->file_manager_->upload(file_id, upload_dialog_photo_callback_, 32, 0); } diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 580e88ad..ee40bff7 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -2583,7 +2583,7 @@ class MessagesManager : public Actor { Promise promise; DialogId dialog_id; }; - std::unordered_map uploaded_dialog_photos_; // file_id -> ... + std::unordered_map being_uploaded_dialog_photos_; // file_id -> ... struct PendingMessageGroupSend { DialogId dialog_id;