Add some FileView emptiness checks.
This commit is contained in:
parent
9651243eaa
commit
6801eabb8d
@ -993,8 +993,8 @@ void BackgroundManager::add_background(const Background &background, bool replac
|
|||||||
|
|
||||||
if (result->file_id != background.file_id) {
|
if (result->file_id != background.file_id) {
|
||||||
if (result->file_id.is_valid()) {
|
if (result->file_id.is_valid()) {
|
||||||
if (td_->file_manager_->get_file_view(result->file_id).file_id() !=
|
if (!background.file_id.is_valid() || td_->file_manager_->get_file_view(result->file_id).file_id() !=
|
||||||
td_->file_manager_->get_file_view(background.file_id).file_id()) {
|
td_->file_manager_->get_file_view(background.file_id).file_id()) {
|
||||||
LOG(ERROR) << "Background file has changed from " << result->file_id << " to " << background.file_id;
|
LOG(ERROR) << "Background file has changed from " << result->file_id << " to " << background.file_id;
|
||||||
file_id_to_background_id_.erase(result->file_id);
|
file_id_to_background_id_.erase(result->file_id);
|
||||||
result->file_source_id = FileSourceId();
|
result->file_source_id = FileSourceId();
|
||||||
|
@ -396,6 +396,7 @@ telegram_api::object_ptr<telegram_api::InputSecureFile> get_input_secure_file_ob
|
|||||||
LOG(ERROR) << "Receive invalid EncryptedSecureFile";
|
LOG(ERROR) << "Receive invalid EncryptedSecureFile";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
CHECK(input_file.file_id.is_valid());
|
||||||
CHECK(file_manager->get_file_view(file.file.file_id).file_id() ==
|
CHECK(file_manager->get_file_view(file.file.file_id).file_id() ==
|
||||||
file_manager->get_file_view(input_file.file_id).file_id());
|
file_manager->get_file_view(input_file.file_id).file_id());
|
||||||
auto res = std::move(input_file.input_file);
|
auto res = std::move(input_file.input_file);
|
||||||
|
@ -95,6 +95,7 @@ class FileDownloadGenerateActor final : public FileGenerateActor {
|
|||||||
send_lambda(G()->file_manager(),
|
send_lambda(G()->file_manager(),
|
||||||
[file_type = file_type_, file_id = file_id_, callback = std::move(callback_)]() mutable {
|
[file_type = file_type_, file_id = file_id_, callback = std::move(callback_)]() mutable {
|
||||||
auto file_view = G()->td().get_actor_unsafe()->file_manager_->get_file_view(file_id);
|
auto file_view = G()->td().get_actor_unsafe()->file_manager_->get_file_view(file_id);
|
||||||
|
CHECK(!file_view.empty());
|
||||||
if (file_view.has_local_location()) {
|
if (file_view.has_local_location()) {
|
||||||
auto location = file_view.local_location();
|
auto location = file_view.local_location();
|
||||||
location.file_type_ = file_type;
|
location.file_type_ = file_type;
|
||||||
|
@ -1919,6 +1919,7 @@ void FileManager::load_from_pmc(FileNodePtr node, bool new_remote, bool new_loca
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto file_view = get_file_view(file_id);
|
auto file_view = get_file_view(file_id);
|
||||||
|
CHECK(!file_view.empty());
|
||||||
|
|
||||||
FullRemoteFileLocation remote;
|
FullRemoteFileLocation remote;
|
||||||
FullLocalFileLocation local;
|
FullLocalFileLocation local;
|
||||||
@ -1929,7 +1930,7 @@ void FileManager::load_from_pmc(FileNodePtr node, bool new_remote, bool new_loca
|
|||||||
}
|
}
|
||||||
new_local &= file_view.has_local_location();
|
new_local &= file_view.has_local_location();
|
||||||
if (new_local) {
|
if (new_local) {
|
||||||
local = get_file_view(file_id).local_location();
|
local = file_view.local_location();
|
||||||
prepare_path_for_pmc(local.file_type_, local.path_);
|
prepare_path_for_pmc(local.file_type_, local.path_);
|
||||||
}
|
}
|
||||||
new_generate &= file_view.has_generate_location();
|
new_generate &= file_view.has_generate_location();
|
||||||
@ -3127,7 +3128,7 @@ Result<FileId> FileManager::get_input_file_id(FileType type, const tl_object_ptr
|
|||||||
auto it = file_hash_to_file_id_.find(hash);
|
auto it = file_hash_to_file_id_.find(hash);
|
||||||
if (it != file_hash_to_file_id_.end()) {
|
if (it != file_hash_to_file_id_.end()) {
|
||||||
auto file_view = get_file_view(it->second);
|
auto file_view = get_file_view(it->second);
|
||||||
if (file_view.has_remote_location() && !file_view.remote_location().is_web()) {
|
if (!file_view.empty() && file_view.has_remote_location() && !file_view.remote_location().is_web()) {
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user