Disable deletion of old document info.

GitOrigin-RevId: 23a398aede9e1cae62d4e679474f9b82f55cefa4
This commit is contained in:
levlam 2018-01-05 18:50:35 +03:00
parent 0912cf4573
commit 2bd0b62f9a
8 changed files with 29 additions and 8 deletions

View File

@ -129,6 +129,7 @@ tl_object_ptr<td_api::animation> AnimationsManager::get_animation_object(FileId
FileId AnimationsManager::on_get_animation(std::unique_ptr<Animation> new_animation, bool replace) {
auto file_id = new_animation->file_id;
LOG(INFO) << "Receive animation " << file_id;
auto &a = animations_[file_id];
if (a == nullptr) {
a = std::move(new_animation);
@ -207,6 +208,8 @@ bool AnimationsManager::merge_animations(FileId new_id, FileId old_id, bool can_
LOG(ERROR) << "Old file id is invalid";
return true;
}
LOG(INFO) << "Merge animations " << new_id << " and " << old_id;
const Animation *old_ = get_animation(old_id);
CHECK(old_ != nullptr);
if (old_id == new_id) {

View File

@ -50,6 +50,7 @@ tl_object_ptr<td_api::audio> AudiosManager::get_audio_object(FileId file_id) {
FileId AudiosManager::on_get_audio(std::unique_ptr<Audio> new_audio, bool replace) {
auto file_id = new_audio->file_id;
LOG(INFO) << "Receive audio " << file_id;
auto &a = audios_[file_id];
if (a == nullptr) {
a = std::move(new_audio);
@ -113,6 +114,8 @@ bool AudiosManager::merge_audios(FileId new_id, FileId old_id, bool can_delete_o
LOG(ERROR) << "Old file id is invalid";
return true;
}
LOG(INFO) << "Merge audios " << new_id << " and " << old_id;
const Audio *old_ = get_audio(old_id);
CHECK(old_ != nullptr);
if (old_id == new_id) {

View File

@ -279,6 +279,7 @@ std::pair<DocumentsManager::DocumentType, FileId> DocumentsManager::on_get_docum
FileId DocumentsManager::on_get_document(std::unique_ptr<Document> new_document, bool replace) {
auto file_id = new_document->file_id;
LOG(INFO) << "Receive document " << file_id;
auto &d = documents_[new_document->file_id];
if (d == nullptr) {
d = std::move(new_document);
@ -436,6 +437,8 @@ bool DocumentsManager::merge_documents(FileId new_id, FileId old_id, bool can_de
LOG(ERROR) << "Old file id is invalid";
return true;
}
LOG(INFO) << "Merge documents " << new_id << " and " << old_id;
const Document *old_ = get_document(old_id);
CHECK(old_ != nullptr);
if (old_id == new_id) {

View File

@ -17803,7 +17803,7 @@ FullMessageId MessagesManager::on_send_message_success(int64 random_id, MessageI
case MessageAnimation::ID: {
auto content = static_cast<MessageAnimation *>(sent_message->content.get());
if (new_file_id != content->file_id) {
td_->animations_manager_->merge_animations(new_file_id, content->file_id, true);
td_->animations_manager_->merge_animations(new_file_id, content->file_id, false);
content->file_id = new_file_id;
is_content_changed = true;
}
@ -17812,7 +17812,7 @@ FullMessageId MessagesManager::on_send_message_success(int64 random_id, MessageI
case MessageAudio::ID: {
auto content = static_cast<MessageAudio *>(sent_message->content.get());
if (new_file_id != content->file_id) {
td_->audios_manager_->merge_audios(new_file_id, content->file_id, true);
td_->audios_manager_->merge_audios(new_file_id, content->file_id, false);
content->file_id = new_file_id;
is_content_changed = true;
}
@ -17821,7 +17821,7 @@ FullMessageId MessagesManager::on_send_message_success(int64 random_id, MessageI
case MessageDocument::ID: {
auto content = static_cast<MessageDocument *>(sent_message->content.get());
if (new_file_id != content->file_id) {
td_->documents_manager_->merge_documents(new_file_id, content->file_id, true);
td_->documents_manager_->merge_documents(new_file_id, content->file_id, false);
content->file_id = new_file_id;
is_content_changed = true;
}
@ -17843,7 +17843,7 @@ FullMessageId MessagesManager::on_send_message_success(int64 random_id, MessageI
case MessageSticker::ID: {
auto content = static_cast<MessageSticker *>(sent_message->content.get());
if (new_file_id != content->file_id) {
td_->stickers_manager_->merge_stickers(new_file_id, content->file_id, true);
td_->stickers_manager_->merge_stickers(new_file_id, content->file_id, false);
content->file_id = new_file_id;
is_content_changed = true;
}
@ -17852,7 +17852,7 @@ FullMessageId MessagesManager::on_send_message_success(int64 random_id, MessageI
case MessageVideo::ID: {
auto content = static_cast<MessageVideo *>(sent_message->content.get());
if (new_file_id != content->file_id) {
td_->videos_manager_->merge_videos(new_file_id, content->file_id, true);
td_->videos_manager_->merge_videos(new_file_id, content->file_id, false);
content->file_id = new_file_id;
is_content_changed = true;
}
@ -17861,7 +17861,7 @@ FullMessageId MessagesManager::on_send_message_success(int64 random_id, MessageI
case MessageVideoNote::ID: {
auto content = static_cast<MessageVideoNote *>(sent_message->content.get());
if (new_file_id != content->file_id) {
td_->video_notes_manager_->merge_video_notes(new_file_id, content->file_id, true);
td_->video_notes_manager_->merge_video_notes(new_file_id, content->file_id, false);
content->file_id = new_file_id;
is_content_changed = true;
}
@ -17870,7 +17870,7 @@ FullMessageId MessagesManager::on_send_message_success(int64 random_id, MessageI
case MessageVoiceNote::ID: {
auto content = static_cast<MessageVoiceNote *>(sent_message->content.get());
if (new_file_id != content->file_id) {
td_->voice_notes_manager_->merge_voice_notes(new_file_id, content->file_id, true);
td_->voice_notes_manager_->merge_voice_notes(new_file_id, content->file_id, false);
content->file_id = new_file_id;
is_content_changed = true;
}
@ -21579,7 +21579,7 @@ bool MessagesManager::update_message_content(DialogId dialog_id, const Message *
bool need_update = false;
int32 old_content_type = old_content->get_id();
int32 new_content_type = new_content->get_id();
bool can_delete_old_document = old_message->message_id.is_yet_unsent();
bool can_delete_old_document = old_message->message_id.is_yet_unsent() && false;
if (old_content_type != new_content_type) {
need_update = true;
LOG(INFO) << "Message content has changed its type from " << old_content_type << " to " << new_content_type;

View File

@ -855,6 +855,7 @@ tl_object_ptr<telegram_api::InputStickerSet> StickersManager::get_input_sticker_
FileId StickersManager::on_get_sticker(std::unique_ptr<Sticker> new_sticker, bool replace) {
auto file_id = new_sticker->file_id;
LOG(INFO) << "Receive sticker " << file_id;
auto &s = stickers_[file_id];
if (s == nullptr) {
s = std::move(new_sticker);
@ -1060,6 +1061,8 @@ bool StickersManager::merge_stickers(FileId new_id, FileId old_id, bool can_dele
LOG(ERROR) << "Old file id is invalid";
return true;
}
LOG(INFO) << "Merge stickers " << new_id << " and " << old_id;
const Sticker *old_ = get_sticker(old_id);
CHECK(old_ != nullptr);
if (old_id == new_id) {

View File

@ -50,6 +50,7 @@ tl_object_ptr<td_api::videoNote> VideoNotesManager::get_video_note_object(FileId
FileId VideoNotesManager::on_get_video_note(std::unique_ptr<VideoNote> new_video_note, bool replace) {
auto file_id = new_video_note->file_id;
LOG(INFO) << "Receive video note " << file_id;
auto &v = video_notes_[file_id];
if (v == nullptr) {
v = std::move(new_video_note);
@ -113,6 +114,8 @@ bool VideoNotesManager::merge_video_notes(FileId new_id, FileId old_id, bool can
LOG(ERROR) << "Old file id is invalid";
return true;
}
LOG(INFO) << "Merge video notes " << new_id << " and " << old_id;
const VideoNote *old_ = get_video_note(old_id);
CHECK(old_ != nullptr);
if (old_id == new_id) {

View File

@ -51,6 +51,7 @@ tl_object_ptr<td_api::video> VideosManager::get_video_object(FileId file_id) {
FileId VideosManager::on_get_video(std::unique_ptr<Video> new_video, bool replace) {
auto file_id = new_video->file_id;
LOG(INFO) << "Receive video " << file_id;
auto &v = videos_[file_id];
if (v == nullptr) {
v = std::move(new_video);
@ -132,6 +133,8 @@ bool VideosManager::merge_videos(FileId new_id, FileId old_id, bool can_delete_o
LOG(ERROR) << "Old file id is invalid";
return true;
}
LOG(INFO) << "Merge videos " << new_id << " and " << old_id;
const Video *old_ = get_video(old_id);
CHECK(old_ != nullptr);
if (old_id == new_id) {

View File

@ -49,6 +49,7 @@ tl_object_ptr<td_api::voiceNote> VoiceNotesManager::get_voice_note_object(FileId
FileId VoiceNotesManager::on_get_voice_note(std::unique_ptr<VoiceNote> new_voice_note, bool replace) {
auto file_id = new_voice_note->file_id;
LOG(INFO) << "Receive voice note " << file_id;
auto &v = voice_notes_[file_id];
if (v == nullptr) {
v = std::move(new_voice_note);
@ -95,6 +96,8 @@ bool VoiceNotesManager::merge_voice_notes(FileId new_id, FileId old_id, bool can
LOG(ERROR) << "Old file id is invalid";
return true;
}
LOG(INFO) << "Merge voice notes " << new_id << " and " << old_id;
const VoiceNote *old_ = get_voice_note(old_id);
CHECK(old_ != nullptr);
if (old_id == new_id) {