From 8cb1a682cc454c1e83fd509ee1b1cde8c18d6f74 Mon Sep 17 00:00:00 2001 From: levlam Date: Sun, 22 Apr 2018 20:26:00 +0300 Subject: [PATCH] Ignore negative cache in getWebPageInstantView. GitOrigin-RevId: 3d4b5f4db209e6c82ed576360ef5867f2c85b9a7 --- td/telegram/Td.cpp | 3 ++- td/telegram/WebPagesManager.cpp | 8 +++++++- td/telegram/WebPagesManager.h | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index f958ac29..acf46934 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -1883,7 +1883,8 @@ class GetWebPageInstantViewRequest : public RequestActor<> { WebPageId web_page_id_; void do_run(Promise &&promise) override { - web_page_id_ = td->web_pages_manager_->get_web_page_instant_view(url_, force_full_, std::move(promise)); + web_page_id_ = + td->web_pages_manager_->get_web_page_instant_view(url_, force_full_, get_tries() < 3, std::move(promise)); } void do_send_result() override { diff --git a/td/telegram/WebPagesManager.cpp b/td/telegram/WebPagesManager.cpp index acebe2a0..36a9cd03 100644 --- a/td/telegram/WebPagesManager.cpp +++ b/td/telegram/WebPagesManager.cpp @@ -1733,10 +1733,16 @@ tl_object_ptr WebPagesManager::get_web_page_preview_result(int6 return get_web_page_object(web_page_id); } -WebPageId WebPagesManager::get_web_page_instant_view(const string &url, bool force_full, Promise &&promise) { +WebPageId WebPagesManager::get_web_page_instant_view(const string &url, bool force_full, bool force, + Promise &&promise) { LOG(INFO) << "Trying to get web page instant view for the url \"" << url << '"'; auto it = url_to_web_page_id_.find(url); if (it != url_to_web_page_id_.end()) { + if (it->second == WebPageId() && !force) { + // ignore negative caching + reload_web_page_by_url(url, std::move(promise)); + return WebPageId(); + } return get_web_page_instant_view(it->second, force_full, std::move(promise)); } diff --git a/td/telegram/WebPagesManager.h b/td/telegram/WebPagesManager.h index 7c491a8f..360a6f40 100644 --- a/td/telegram/WebPagesManager.h +++ b/td/telegram/WebPagesManager.h @@ -60,7 +60,7 @@ class WebPagesManager : public Actor { tl_object_ptr get_web_page_preview_result(int64 request_id); - WebPageId get_web_page_instant_view(const string &url, bool force_full, Promise &&promise); + WebPageId get_web_page_instant_view(const string &url, bool force_full, bool force, Promise &&promise); WebPageId get_web_page_by_url(const string &url) const;