From 7153a17bd78c17232f202303c493f7c51ab22f40 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 24 Jun 2022 14:59:42 +0300 Subject: [PATCH] Don't check full local locations after loading file from database. --- td/telegram/files/FileManager.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/td/telegram/files/FileManager.cpp b/td/telegram/files/FileManager.cpp index b44fbc628..bd352fed9 100644 --- a/td/telegram/files/FileManager.cpp +++ b/td/telegram/files/FileManager.cpp @@ -1177,8 +1177,9 @@ Result FileManager::register_file(FileData &&data, FileLocationSource fi bool has_remote = data.remote_.type() == RemoteFileLocation::Type::Full; bool has_generate = data.generate_ != nullptr; if (data.local_.type() == LocalFileLocation::Type::Full && !force) { - if (file_location_source == FileLocationSource::FromBinlog || - file_location_source == FileLocationSource::FromDatabase) { + bool is_from_database = file_location_source == FileLocationSource::FromBinlog || + file_location_source == FileLocationSource::FromDatabase; + if (is_from_database) { PathView path_view(data.local_.full().path_); if (path_view.is_relative()) { data.local_.full().path_ = PSTRING() @@ -1186,16 +1187,18 @@ Result FileManager::register_file(FileData &&data, FileLocationSource fi } } - auto status = check_local_location(data.local_.full(), data.size_, skip_file_size_checks); - if (status.is_error()) { - LOG(INFO) << "Invalid " << data.local_.full() << ": " << status << " from " << source; - data.local_ = LocalFileLocation(); - if (data.remote_.type() == RemoteFileLocation::Type::Partial) { - data.remote_ = {}; - } + if (!is_from_database) { + auto status = check_local_location(data.local_.full(), data.size_, skip_file_size_checks); + if (status.is_error()) { + LOG(INFO) << "Invalid " << data.local_.full() << ": " << status << " from " << source; + data.local_ = LocalFileLocation(); + if (data.remote_.type() == RemoteFileLocation::Type::Partial) { + data.remote_ = {}; + } - if (!has_remote && !has_generate) { - return std::move(status); + if (!has_remote && !has_generate) { + return std::move(status); + } } } }