Immediately ignore duplicate and invalid file sources loaded from database.

This commit is contained in:
levlam 2022-10-06 15:15:45 +03:00
parent a235628428
commit 78314b2da9
2 changed files with 6 additions and 4 deletions

View File

@ -122,7 +122,10 @@ void FileData::parse(ParserT &parser, bool register_file_sources) {
if (parser.get_error()) {
return;
}
file_source_ids_.push_back(td->file_reference_manager_->parse_file_source(td, parser));
auto file_source_id = td->file_reference_manager_->parse_file_source(td, parser);
if (file_source_id.is_valid() && !td::contains(file_source_ids_, file_source_id)) {
file_source_ids_.push_back(file_source_id);
}
}
} else {
parser.set_error("Wrong number of file source ids");

View File

@ -1302,9 +1302,8 @@ Result<FileId> FileManager::register_file(FileData &&data, FileLocationSource fi
try_forget_file_id(file_id);
for (auto file_source_id : data.file_source_ids_) {
VLOG(file_references) << "Loaded " << data.file_source_ids_ << " for file " << main_file_id << " from " << source;
if (file_source_id.is_valid()) {
context_->add_file_source(main_file_id, file_source_id);
}
CHECK(file_source_id.is_valid());
context_->add_file_source(main_file_id, file_source_id);
}
return FileId(main_file_id.get(), remote_key);
}