Return only key's suffix in prefix_get.

GitOrigin-RevId: 4e2043356fc69741a881407146fd4e9ca385b258
This commit is contained in:
levlam 2020-04-23 20:27:46 +03:00
parent aa6029f63c
commit 9328c20fcc
3 changed files with 9 additions and 9 deletions

View File

@ -10319,7 +10319,7 @@ void MessagesManager::init() {
auto last_database_server_dialog_dates = G()->td_db()->get_binlog_pmc()->prefix_get("last_server_dialog_date");
for (auto &it : last_database_server_dialog_dates) {
auto r_folder_id = to_integer_safe<int32>(Slice(it.first).substr(Slice("last_server_dialog_date").size()));
auto r_folder_id = to_integer_safe<int32>(it.first);
if (r_folder_id.is_error()) {
LOG(ERROR) << "Can't parse folder ID from " << it.first;
continue;
@ -10368,7 +10368,7 @@ void MessagesManager::init() {
auto unread_message_counts = G()->td_db()->get_binlog_pmc()->prefix_get("unread_message_count");
for (auto &it : unread_message_counts) {
auto r_folder_id = to_integer_safe<int32>(Slice(it.first).substr(Slice("unread_message_count").size()));
auto r_folder_id = to_integer_safe<int32>(it.first);
if (r_folder_id.is_error()) {
LOG(ERROR) << "Can't parse folder ID from " << it.first;
continue;
@ -10393,7 +10393,7 @@ void MessagesManager::init() {
auto unread_dialog_counts = G()->td_db()->get_binlog_pmc()->prefix_get("unread_dialog_count");
for (auto &it : unread_dialog_counts) {
auto r_folder_id = to_integer_safe<int32>(Slice(it.first).substr(Slice("unread_dialog_count").size()));
auto r_folder_id = to_integer_safe<int32>(it.first);
if (r_folder_id.is_error()) {
LOG(ERROR) << "Can't parse folder ID from " << it.first;
continue;

View File

@ -1078,26 +1078,26 @@ void ConnectionCreator::start_up() {
}
auto proxy_info = G()->td_db()->get_binlog_pmc()->prefix_get("proxy");
auto it = proxy_info.find("proxy_max_id");
auto it = proxy_info.find("_max_id");
if (it != proxy_info.end()) {
max_proxy_id_ = to_integer<int32>(it->second);
proxy_info.erase(it);
}
it = proxy_info.find("proxy_active_id");
it = proxy_info.find("_active_id");
if (it != proxy_info.end()) {
set_active_proxy_id(to_integer<int32>(it->second), true);
proxy_info.erase(it);
}
for (auto &info : proxy_info) {
if (begins_with(info.first, "proxy_used")) {
int32 proxy_id = to_integer_safe<int32>(Slice(info.first).substr(10)).move_as_ok();
if (begins_with(info.first, "_used")) {
int32 proxy_id = to_integer_safe<int32>(Slice(info.first).substr(5)).move_as_ok();
int32 last_used = to_integer_safe<int32>(info.second).move_as_ok();
proxy_last_used_date_[proxy_id] = last_used;
proxy_last_used_saved_date_[proxy_id] = last_used;
} else {
LOG_CHECK(!ends_with(info.first, "_max_id")) << info.first;
int32 proxy_id = info.first == "proxy" ? 1 : to_integer_safe<int32>(Slice(info.first).substr(5)).move_as_ok();
int32 proxy_id = info.first == "" ? 1 : to_integer_safe<int32>(info.first).move_as_ok();
CHECK(proxies_.count(proxy_id) == 0);
log_event_parse(proxies_[proxy_id], info.second).ensure();
if (proxies_[proxy_id].type() == Proxy::Type::None) {

View File

@ -191,7 +191,7 @@ class BinlogKeyValue : public KeyValueSyncInterface {
std::unordered_map<string, string> res;
for (const auto &kv : map_) {
if (begins_with(kv.first, prefix)) {
res[kv.first] = kv.second.first;
res[kv.first.substr(prefix.size())] = kv.second.first;
}
}
return res;