Simplify implementation of merge_* for documents.
This commit is contained in:
parent
33623f9818
commit
ad72974e70
@ -282,13 +282,10 @@ void AnimationsManager::merge_animations(FileId new_id, FileId old_id) {
|
||||
CHECK(old_ != nullptr);
|
||||
|
||||
bool need_merge = true;
|
||||
auto new_it = animations_.find(new_id);
|
||||
if (new_it == animations_.end()) {
|
||||
const auto *new_ = get_animation(new_id);
|
||||
if (new_ == nullptr) {
|
||||
dup_animation(new_id, old_id);
|
||||
} else {
|
||||
Animation *new_ = new_it->second.get();
|
||||
CHECK(new_ != nullptr);
|
||||
|
||||
if (old_->thumbnail != new_->thumbnail) {
|
||||
// LOG_STATUS(td_->file_manager_->merge(new_->thumbnail.file_id, old_->thumbnail.file_id));
|
||||
}
|
||||
|
@ -154,13 +154,10 @@ void AudiosManager::merge_audios(FileId new_id, FileId old_id) {
|
||||
const Audio *old_ = get_audio(old_id);
|
||||
CHECK(old_ != nullptr);
|
||||
|
||||
auto new_it = audios_.find(new_id);
|
||||
if (new_it == audios_.end()) {
|
||||
const auto *new_ = get_audio(new_id);
|
||||
if (new_ == nullptr) {
|
||||
dup_audio(new_id, old_id);
|
||||
} else {
|
||||
Audio *new_ = new_it->second.get();
|
||||
CHECK(new_ != nullptr);
|
||||
|
||||
if (!old_->mime_type.empty() && old_->mime_type != new_->mime_type) {
|
||||
LOG(INFO) << "Audio has changed: mime_type = (" << old_->mime_type << ", " << new_->mime_type << ")";
|
||||
}
|
||||
|
@ -716,13 +716,10 @@ void DocumentsManager::merge_documents(FileId new_id, FileId old_id) {
|
||||
const GeneralDocument *old_ = get_document(old_id);
|
||||
CHECK(old_ != nullptr);
|
||||
|
||||
auto new_it = documents_.find(new_id);
|
||||
if (new_it == documents_.end()) {
|
||||
const auto *new_ = get_document(new_id);
|
||||
if (new_ == nullptr) {
|
||||
dup_document(new_id, old_id);
|
||||
} else {
|
||||
GeneralDocument *new_ = new_it->second.get();
|
||||
CHECK(new_ != nullptr);
|
||||
|
||||
if (old_->thumbnail != new_->thumbnail) {
|
||||
// LOG_STATUS(td_->file_manager_->merge(new_->thumbnail.file_id, old_->thumbnail.file_id));
|
||||
}
|
||||
|
@ -2817,13 +2817,10 @@ void StickersManager::merge_stickers(FileId new_id, FileId old_id) {
|
||||
const Sticker *old_ = get_sticker(old_id);
|
||||
CHECK(old_ != nullptr);
|
||||
|
||||
auto new_it = stickers_.find(new_id);
|
||||
if (new_it == stickers_.end()) {
|
||||
const auto *new_ = get_sticker(new_id);
|
||||
if (new_ == nullptr) {
|
||||
dup_sticker(new_id, old_id);
|
||||
} else {
|
||||
Sticker *new_ = new_it->second.get();
|
||||
CHECK(new_ != nullptr);
|
||||
|
||||
if (old_->set_id == new_->set_id &&
|
||||
(old_->alt != new_->alt || old_->set_id != new_->set_id ||
|
||||
(!is_sticker_format_vector(old_->format) && !is_sticker_format_vector(new_->format) &&
|
||||
|
@ -117,12 +117,10 @@ void VideoNotesManager::merge_video_notes(FileId new_id, FileId old_id) {
|
||||
const VideoNote *old_ = get_video_note(old_id);
|
||||
CHECK(old_ != nullptr);
|
||||
|
||||
auto new_it = video_notes_.find(new_id);
|
||||
if (new_it == video_notes_.end()) {
|
||||
const auto *new_ = get_video_note(new_id);
|
||||
if (new_ == nullptr) {
|
||||
dup_video_note(new_id, old_id);
|
||||
} else {
|
||||
VideoNote *new_ = new_it->second.get();
|
||||
CHECK(new_ != nullptr);
|
||||
if (old_->thumbnail != new_->thumbnail) {
|
||||
// LOG_STATUS(td_->file_manager_->merge(new_->thumbnail.file_id, old_->thumbnail.file_id));
|
||||
}
|
||||
|
@ -155,13 +155,10 @@ void VideosManager::merge_videos(FileId new_id, FileId old_id) {
|
||||
const Video *old_ = get_video(old_id);
|
||||
CHECK(old_ != nullptr);
|
||||
|
||||
auto new_it = videos_.find(new_id);
|
||||
if (new_it == videos_.end()) {
|
||||
const auto *new_ = get_video(new_id);
|
||||
if (new_ == nullptr) {
|
||||
dup_video(new_id, old_id);
|
||||
} else {
|
||||
Video *new_ = new_it->second.get();
|
||||
CHECK(new_ != nullptr);
|
||||
|
||||
if (!old_->mime_type.empty() && old_->mime_type != new_->mime_type) {
|
||||
LOG(INFO) << "Video has changed: mime_type = (" << old_->mime_type << ", " << new_->mime_type << ")";
|
||||
}
|
||||
|
@ -236,13 +236,10 @@ void VoiceNotesManager::merge_voice_notes(FileId new_id, FileId old_id) {
|
||||
const VoiceNote *old_ = get_voice_note(old_id);
|
||||
CHECK(old_ != nullptr);
|
||||
|
||||
auto new_it = voice_notes_.find(new_id);
|
||||
if (new_it == voice_notes_.end()) {
|
||||
const auto *new_ = get_voice_note(new_id);
|
||||
if (new_ == nullptr) {
|
||||
dup_voice_note(new_id, old_id);
|
||||
} else {
|
||||
VoiceNote *new_ = new_it->second.get();
|
||||
CHECK(new_ != nullptr);
|
||||
|
||||
if (!old_->mime_type.empty() && old_->mime_type != new_->mime_type) {
|
||||
LOG(INFO) << "Voice note has changed: mime_type = (" << old_->mime_type << ", " << new_->mime_type << ")";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user