Add source to store_sticker_set.
This commit is contained in:
parent
43855f0ce4
commit
6dd7c73765
@ -2883,7 +2883,7 @@ StickerSetId StickersManager::on_get_messages_sticker_set(StickerSetId sticker_s
|
||||
(td_->auth_manager_->is_bot() ? Random::fast(10 * 60, 15 * 60) : Random::fast(30 * 60, 50 * 60));
|
||||
|
||||
if (s->is_loaded) {
|
||||
update_sticker_set(s);
|
||||
update_sticker_set(s, "on_get_messages_sticker_set");
|
||||
send_update_installed_sticker_sets();
|
||||
return set_id;
|
||||
}
|
||||
@ -2941,7 +2941,7 @@ StickerSetId StickersManager::on_get_messages_sticker_set(StickerSetId sticker_s
|
||||
}
|
||||
}
|
||||
|
||||
update_sticker_set(s);
|
||||
update_sticker_set(s, "on_get_messages_sticker_set 2");
|
||||
update_load_requests(s, true, Status::OK());
|
||||
send_update_installed_sticker_sets();
|
||||
|
||||
@ -3071,7 +3071,7 @@ void StickersManager::on_get_installed_sticker_sets(bool is_masks,
|
||||
installed_sticker_set_ids.push_back(set_id);
|
||||
uninstalled_sticker_sets.erase(set_id);
|
||||
}
|
||||
update_sticker_set(sticker_set);
|
||||
update_sticker_set(sticker_set, "on_get_installed_sticker_sets");
|
||||
|
||||
if (!sticker_set->is_archived && !sticker_set->is_loaded) {
|
||||
sets_to_load.push_back(set_id);
|
||||
@ -3090,7 +3090,7 @@ void StickersManager::on_get_installed_sticker_sets(bool is_masks,
|
||||
CHECK(sticker_set != nullptr);
|
||||
CHECK(sticker_set->is_installed && !sticker_set->is_archived);
|
||||
on_update_sticker_set(sticker_set, false, false, true);
|
||||
update_sticker_set(sticker_set);
|
||||
update_sticker_set(sticker_set, "on_get_installed_sticker_sets 2");
|
||||
}
|
||||
|
||||
on_load_installed_sticker_sets_finished(is_masks, std::move(installed_sticker_set_ids));
|
||||
@ -3551,7 +3551,7 @@ void StickersManager::on_find_sticker_sets_success(
|
||||
continue;
|
||||
}
|
||||
|
||||
update_sticker_set(get_sticker_set(set_id));
|
||||
update_sticker_set(get_sticker_set(set_id), "on_find_sticker_sets_success");
|
||||
sticker_set_ids.push_back(set_id);
|
||||
}
|
||||
|
||||
@ -3803,9 +3803,9 @@ string StickersManager::get_full_sticker_set_database_key(StickerSetId set_id) {
|
||||
return PSTRING() << "ssf" << set_id.get();
|
||||
}
|
||||
|
||||
string StickersManager::get_sticker_set_database_value(const StickerSet *s, bool with_stickers) {
|
||||
string StickersManager::get_sticker_set_database_value(const StickerSet *s, bool with_stickers, const char *source) {
|
||||
LogEventStorerCalcLength storer_calc_length;
|
||||
store_sticker_set(s, with_stickers, storer_calc_length);
|
||||
store_sticker_set(s, with_stickers, storer_calc_length, source);
|
||||
|
||||
BufferSlice value_buffer{storer_calc_length.get_length()};
|
||||
auto value = value_buffer.as_slice();
|
||||
@ -3813,23 +3813,23 @@ string StickersManager::get_sticker_set_database_value(const StickerSet *s, bool
|
||||
LOG(DEBUG) << "Serialized size of " << s->id << " is " << value.size();
|
||||
|
||||
LogEventStorerUnsafe storer_unsafe(value.ubegin());
|
||||
store_sticker_set(s, with_stickers, storer_unsafe);
|
||||
store_sticker_set(s, with_stickers, storer_unsafe, source);
|
||||
|
||||
return value.str();
|
||||
}
|
||||
|
||||
void StickersManager::update_sticker_set(StickerSet *sticker_set) {
|
||||
void StickersManager::update_sticker_set(StickerSet *sticker_set, const char *source) {
|
||||
CHECK(sticker_set != nullptr);
|
||||
if (sticker_set->is_changed || sticker_set->need_save_to_database) {
|
||||
if (G()->parameters().use_file_db && !G()->close_flag()) {
|
||||
LOG(INFO) << "Save " << sticker_set->id << " to database";
|
||||
LOG(INFO) << "Save " << sticker_set->id << " to database from " << source;
|
||||
if (sticker_set->is_inited) {
|
||||
G()->td_db()->get_sqlite_pmc()->set(get_sticker_set_database_key(sticker_set->id),
|
||||
get_sticker_set_database_value(sticker_set, false), Auto());
|
||||
get_sticker_set_database_value(sticker_set, false, source), Auto());
|
||||
}
|
||||
if (sticker_set->was_loaded) {
|
||||
G()->td_db()->get_sqlite_pmc()->set(get_full_sticker_set_database_key(sticker_set->id),
|
||||
get_sticker_set_database_value(sticker_set, true), Auto());
|
||||
get_sticker_set_database_value(sticker_set, true, source), Auto());
|
||||
}
|
||||
}
|
||||
if (sticker_set->is_changed && sticker_set->was_loaded && sticker_set->was_update_sent) {
|
||||
@ -3970,7 +3970,7 @@ void StickersManager::on_load_sticker_set_from_database(StickerSetId sticker_set
|
||||
|
||||
if (with_stickers && old_sticker_count < 5 && old_sticker_count < sticker_set->sticker_ids.size()) {
|
||||
sticker_set->need_save_to_database = true;
|
||||
update_sticker_set(sticker_set);
|
||||
update_sticker_set(sticker_set, "on_load_sticker_set_from_database");
|
||||
}
|
||||
|
||||
update_load_requests(sticker_set, with_stickers, Status::OK());
|
||||
@ -3994,7 +3994,7 @@ void StickersManager::on_install_sticker_set(StickerSetId set_id, bool is_archiv
|
||||
StickerSet *sticker_set = get_sticker_set(set_id);
|
||||
CHECK(sticker_set != nullptr);
|
||||
on_update_sticker_set(sticker_set, true, is_archived, true);
|
||||
update_sticker_set(sticker_set);
|
||||
update_sticker_set(sticker_set, "on_install_sticker_set");
|
||||
|
||||
switch (result->get_id()) {
|
||||
case telegram_api::messages_stickerSetInstallResultSuccess::ID:
|
||||
@ -4007,7 +4007,7 @@ void StickersManager::on_install_sticker_set(StickerSetId set_id, bool is_archiv
|
||||
if (archived_sticker_set_id.is_valid()) {
|
||||
auto archived_sticker_set = get_sticker_set(archived_sticker_set_id);
|
||||
CHECK(archived_sticker_set != nullptr);
|
||||
update_sticker_set(archived_sticker_set);
|
||||
update_sticker_set(archived_sticker_set, "on_install_sticker_set 2");
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -4023,7 +4023,7 @@ void StickersManager::on_uninstall_sticker_set(StickerSetId set_id) {
|
||||
StickerSet *sticker_set = get_sticker_set(set_id);
|
||||
CHECK(sticker_set != nullptr);
|
||||
on_update_sticker_set(sticker_set, false, false, true);
|
||||
update_sticker_set(sticker_set);
|
||||
update_sticker_set(sticker_set, "on_uninstall_sticker_set");
|
||||
send_update_installed_sticker_sets();
|
||||
}
|
||||
|
||||
@ -4679,7 +4679,7 @@ void StickersManager::view_featured_sticker_sets(const vector<StickerSetId> &sti
|
||||
}
|
||||
set->is_viewed = true;
|
||||
pending_viewed_featured_sticker_set_ids_.insert(sticker_set_id);
|
||||
update_sticker_set(set);
|
||||
update_sticker_set(set, "view_featured_sticker_sets");
|
||||
}
|
||||
}
|
||||
|
||||
@ -4773,7 +4773,7 @@ void StickersManager::on_get_archived_sticker_sets(
|
||||
if (sticker_set_id.is_valid()) {
|
||||
auto sticker_set = get_sticker_set(sticker_set_id);
|
||||
CHECK(sticker_set != nullptr);
|
||||
update_sticker_set(sticker_set);
|
||||
update_sticker_set(sticker_set, "on_get_archived_sticker_sets");
|
||||
|
||||
if (!td::contains(sticker_set_ids, sticker_set_id)) {
|
||||
sticker_set_ids.push_back(sticker_set_id);
|
||||
@ -4963,7 +4963,7 @@ void StickersManager::on_get_featured_sticker_sets(
|
||||
set->is_changed = true;
|
||||
}
|
||||
|
||||
update_sticker_set(set);
|
||||
update_sticker_set(set, "on_get_archived_sticker_sets 2");
|
||||
|
||||
featured_sticker_set_ids.push_back(set_id);
|
||||
}
|
||||
@ -5236,7 +5236,7 @@ void StickersManager::on_get_attached_sticker_sets(
|
||||
if (sticker_set_id.is_valid()) {
|
||||
auto sticker_set = get_sticker_set(sticker_set_id);
|
||||
CHECK(sticker_set != nullptr);
|
||||
update_sticker_set(sticker_set);
|
||||
update_sticker_set(sticker_set, "on_get_attached_sticker_sets");
|
||||
|
||||
sticker_set_ids.push_back(sticker_set_id);
|
||||
}
|
||||
|
@ -480,9 +480,9 @@ class StickersManager final : public Actor {
|
||||
|
||||
static string get_full_sticker_set_database_key(StickerSetId set_id);
|
||||
|
||||
string get_sticker_set_database_value(const StickerSet *s, bool with_stickers);
|
||||
string get_sticker_set_database_value(const StickerSet *s, bool with_stickers, const char *source);
|
||||
|
||||
void update_sticker_set(StickerSet *sticker_set);
|
||||
void update_sticker_set(StickerSet *sticker_set, const char *source);
|
||||
|
||||
void load_sticker_sets(vector<StickerSetId> &&sticker_set_ids, Promise<Unit> &&promise);
|
||||
|
||||
@ -578,7 +578,7 @@ class StickersManager final : public Actor {
|
||||
void save_favorite_stickers_to_database();
|
||||
|
||||
template <class StorerT>
|
||||
void store_sticker_set(const StickerSet *sticker_set, bool with_stickers, StorerT &storer) const;
|
||||
void store_sticker_set(const StickerSet *sticker_set, bool with_stickers, StorerT &storer, const char *source) const;
|
||||
|
||||
template <class ParserT>
|
||||
void parse_sticker_set(StickerSet *sticker_set, ParserT &parser);
|
||||
|
@ -124,7 +124,8 @@ FileId StickersManager::parse_sticker(bool in_sticker_set, ParserT &parser) {
|
||||
}
|
||||
|
||||
template <class StorerT>
|
||||
void StickersManager::store_sticker_set(const StickerSet *sticker_set, bool with_stickers, StorerT &storer) const {
|
||||
void StickersManager::store_sticker_set(const StickerSet *sticker_set, bool with_stickers, StorerT &storer,
|
||||
const char *source) const {
|
||||
size_t stickers_limit = with_stickers ? sticker_set->sticker_ids.size() : 5;
|
||||
bool is_full = sticker_set->sticker_ids.size() <= stickers_limit;
|
||||
bool was_loaded = sticker_set->was_loaded && is_full;
|
||||
@ -169,7 +170,7 @@ void StickersManager::store_sticker_set(const StickerSet *sticker_set, bool with
|
||||
store(stored_sticker_count, storer);
|
||||
for (uint32 i = 0; i < stored_sticker_count; i++) {
|
||||
auto sticker_id = sticker_set->sticker_ids[i];
|
||||
store_sticker(sticker_id, true, storer, "store_sticker_set");
|
||||
store_sticker(sticker_id, true, storer, source);
|
||||
|
||||
if (was_loaded) {
|
||||
auto it = sticker_set->sticker_emojis_map_.find(sticker_id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user