From ecceb1c47239e3805c1b537ba6abacd26dfa5035 Mon Sep 17 00:00:00 2001 From: levlam Date: Sun, 13 Nov 2022 11:56:52 +0300 Subject: [PATCH] Fix file registration. --- td/telegram/files/FileManager.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/td/telegram/files/FileManager.cpp b/td/telegram/files/FileManager.cpp index ceca92d86..5f928c55a 100644 --- a/td/telegram/files/FileManager.cpp +++ b/td/telegram/files/FileManager.cpp @@ -1282,6 +1282,7 @@ Result FileManager::register_file(FileData &&data, FileLocationSource fi auto register_location = [&](const auto &location, auto &mp) -> FileId * { auto &other_id = mp[location]; if (other_id.empty()) { + other_id = file_id; return &other_id; } else { to_merge.push_back(other_id); @@ -1333,10 +1334,10 @@ Result FileManager::register_file(FileData &&data, FileLocationSource fi try_flush_node(get_file_node(file_id), "register_file"); auto main_file_id = get_file_node(file_id)->main_file_id_; if (main_file_id != file_id) { - if (new_local_file_id != nullptr && *new_local_file_id == file_id) { + if (new_local_file_id != nullptr) { *new_local_file_id = main_file_id; } - if (new_generate_file_id != nullptr && *new_generate_file_id == file_id) { + if (new_generate_file_id != nullptr) { *new_generate_file_id = main_file_id; } try_forget_file_id(file_id);