Fix main_file_id_priority.
GitOrigin-RevId: 35ab98806707c7b62378a90e35422b59c83fc8a8
This commit is contained in:
parent
ff39e46a64
commit
648a8eb0af
@ -129,7 +129,7 @@ tl_object_ptr<td_api::animation> AnimationsManager::get_animation_object(FileId
|
||||
|
||||
FileId AnimationsManager::on_get_animation(std::unique_ptr<Animation> new_animation, bool replace) {
|
||||
auto file_id = new_animation->file_id;
|
||||
LOG(INFO) << "Receive animation " << file_id;
|
||||
LOG(INFO) << (replace ? "Replace" : "Add") << " animation " << file_id << " of size " << new_animation->dimensions;
|
||||
auto &a = animations_[file_id];
|
||||
if (a == nullptr) {
|
||||
a = std::move(new_animation);
|
||||
@ -193,6 +193,7 @@ void AnimationsManager::delete_animation_thumbnail(FileId file_id) {
|
||||
}
|
||||
|
||||
FileId AnimationsManager::dup_animation(FileId new_id, FileId old_id) {
|
||||
LOG(INFO) << "Dup animation " << old_id << " to " << new_id;
|
||||
const Animation *old_animation = get_animation(old_id);
|
||||
CHECK(old_animation != nullptr);
|
||||
auto &new_animation = animations_[new_id];
|
||||
|
@ -226,12 +226,12 @@ class FileDb : public FileDbInterface {
|
||||
TRY_RESULT(id, get_id(pmc, key));
|
||||
|
||||
string data_str;
|
||||
int attempts_count = 0;
|
||||
int attempt_count = 0;
|
||||
while (true) {
|
||||
if (attempts_count > 5) {
|
||||
if (attempt_count > 5) {
|
||||
LOG(FATAL) << "cycle in files db?";
|
||||
}
|
||||
attempts_count++;
|
||||
attempt_count++;
|
||||
|
||||
data_str = pmc.get(PSTRING() << "file" << id);
|
||||
auto data_slice = Slice(data_str);
|
||||
|
@ -601,7 +601,7 @@ FileId FileManager::register_remote(const FullRemoteFileLocation &location, Dial
|
||||
data.size_ = size;
|
||||
data.expected_size_ = expected_size;
|
||||
data.name_ = std::move(name);
|
||||
return register_file(std::move(data), FileLocationSource::FromServer, "register_remote").move_as_ok();
|
||||
return register_file(std::move(data), FileLocationSource::FromServer, "register_remote", false).move_as_ok();
|
||||
}
|
||||
|
||||
FileId FileManager::register_url(string url, FileType file_type, DialogId owner_dialog_id) {
|
||||
@ -618,7 +618,7 @@ Result<FileId> FileManager::register_generate(FileType file_type, string origina
|
||||
data.generate_ = GenerateFileLocation(FullGenerateFileLocation(file_type, original_path, std::move(conversion)));
|
||||
data.owner_dialog_id_ = owner_dialog_id;
|
||||
data.expected_size_ = expected_size;
|
||||
return register_file(std::move(data), FileLocationSource::FromServer, "register_generate");
|
||||
return register_file(std::move(data), FileLocationSource::FromServer, "register_generate", false);
|
||||
}
|
||||
|
||||
Result<FileId> FileManager::register_file(FileData data, FileLocationSource file_location_source, const char *source,
|
||||
@ -657,7 +657,8 @@ Result<FileId> FileManager::register_file(FileData data, FileLocationSource file
|
||||
auto &node = file_nodes_[file_node_id];
|
||||
node = std::make_unique<FileNode>(std::move(data.local_), std::move(data.remote_), std::move(data.generate_),
|
||||
data.size_, data.expected_size_, std::move(data.name_), std::move(data.url_),
|
||||
data.owner_dialog_id_, std::move(data.encryption_key_), file_id, 0);
|
||||
data.owner_dialog_id_, std::move(data.encryption_key_), file_id,
|
||||
has_remote ? static_cast<int8>(file_location_source) : 0);
|
||||
node->remote_source_ = file_location_source;
|
||||
node->pmc_id_ = data.pmc_id_;
|
||||
get_file_id_info(file_id)->node_id_ = file_node_id;
|
||||
@ -1189,7 +1190,7 @@ FileNode *FileManager::load_from_pmc(FileNode *node, bool new_remote, bool new_l
|
||||
|
||||
auto load = [&](auto location) {
|
||||
TRY_RESULT(file_data, file_db_->get_file_data_sync(location));
|
||||
TRY_RESULT(new_file_id, register_file(std::move(file_data), FileLocationSource::FromDb, "load_from_pmc"));
|
||||
TRY_RESULT(new_file_id, register_file(std::move(file_data), FileLocationSource::FromDb, "load_from_pmc", false));
|
||||
TRY_RESULT(main_file_id, merge(file_id, new_file_id));
|
||||
file_id = main_file_id;
|
||||
return Status::OK();
|
||||
@ -1733,7 +1734,7 @@ Result<FileId> FileManager::from_persistent_id(CSlice persistent_id, FileType fi
|
||||
}
|
||||
FileData data;
|
||||
data.remote_ = RemoteFileLocation(std::move(remote_location));
|
||||
return register_file(std::move(data), FileLocationSource::FromUser, "from_persistent_id").move_as_ok();
|
||||
return register_file(std::move(data), FileLocationSource::FromUser, "from_persistent_id", false).move_as_ok();
|
||||
}
|
||||
|
||||
FileView FileManager::get_file_view(FileId file_id) const {
|
||||
@ -1784,7 +1785,7 @@ tl_object_ptr<td_api::file> FileManager::get_file_object(FileId file_id, bool wi
|
||||
file_info = get_file_id_info(file_view.file_id());
|
||||
}
|
||||
file_info->send_updates_flag_ = true;
|
||||
VLOG(update_file) << "Update send_updates_flag_ for file "
|
||||
VLOG(update_file) << "Send file " << file_id << " as " << result_file_id << " and update send_updates_flag_ for file "
|
||||
<< (with_main_file_id ? file_view.file_id() : result_file_id);
|
||||
|
||||
return td_api::make_object<td_api::file>(
|
||||
@ -1822,6 +1823,7 @@ Result<FileId> FileManager::check_input_file_id(FileType type, Result<FileId> re
|
||||
// TODO why not return file_id here? We will dup it anyway
|
||||
// But it will not be duped if has_input_media(), so for now we can't return main_file_id
|
||||
file_id = next_file_id();
|
||||
LOG(INFO) << "Dup file " << file_node->main_file_id_ << " without remote location to " << file_id;
|
||||
get_file_id_info(file_id)->node_id_ = file_node_id;
|
||||
file_nodes_[file_node_id]->file_ids_.push_back(file_id);
|
||||
return file_id;
|
||||
|
@ -250,8 +250,7 @@ class FileManager : public FileLoadManager::Callback {
|
||||
int64 expected_size, string name = "") TD_WARN_UNUSED_RESULT;
|
||||
Result<FileId> register_generate(FileType file_type, string original_path, string conversion,
|
||||
DialogId owner_dialog_id, int64 expected_size) TD_WARN_UNUSED_RESULT;
|
||||
Result<FileId> register_file(FileData data, FileLocationSource file_location_source, const char *source,
|
||||
bool force = false);
|
||||
Result<FileId> register_file(FileData data, FileLocationSource file_location_source, const char *source, bool force);
|
||||
|
||||
Result<FileId> merge(FileId x_file_id, FileId y_file_id, bool no_sync = false) TD_WARN_UNUSED_RESULT;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user