From 92c2de8d46c521f63890e9ec935bba6fc5d4d425 Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Sun, 18 Apr 2021 14:59:07 +0400 Subject: [PATCH] Enter InternalServer::m_library_id The new field is intended to serve as a seed for generating semi-stable OPDS feed ids that only need to change when the library is updated. --- src/server/internalServer.cpp | 11 ++++++----- src/server/internalServer.h | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/server/internalServer.cpp b/src/server/internalServer.cpp index dc95add3d..b94f215cd 100644 --- a/src/server/internalServer.cpp +++ b/src/server/internalServer.cpp @@ -170,6 +170,7 @@ bool InternalServer::start() { } auto server_start_time = std::chrono::system_clock::now().time_since_epoch(); m_server_id = kiwix::to_string(server_start_time.count()); + m_library_id = m_server_id; return true; } @@ -738,9 +739,9 @@ std::unique_ptr InternalServer::handle_catalog_v2_root(const RequestCo kainjow::mustache::object{ {"date", gen_date_str()}, {"endpoint_root", root_url + "/catalog/v2"}, - {"feed_id", gen_uuid(m_server_id)}, - {"all_entries_feed_id", gen_uuid(m_server_id + "/entries")}, - {"category_list_feed_id", gen_uuid(m_server_id + "/categories")} + {"feed_id", gen_uuid(m_library_id)}, + {"all_entries_feed_id", gen_uuid(m_library_id + "/entries")}, + {"category_list_feed_id", gen_uuid(m_library_id + "/categories")} }, "application/atom+xml;profile=opds-catalog;kind=navigation" ); @@ -757,7 +758,7 @@ std::unique_ptr InternalServer::handle_catalog_v2_categories(const Req {"name", category}, {"urlencoded_name", urlencodedCategoryName}, {"updated", now}, - {"id", gen_uuid(m_server_id + "/categories/" + urlencodedCategoryName)} + {"id", gen_uuid(m_library_id + "/categories/" + urlencodedCategoryName)} }); } @@ -767,7 +768,7 @@ std::unique_ptr InternalServer::handle_catalog_v2_categories(const Req kainjow::mustache::object{ {"date", now}, {"endpoint_root", root_url + "/catalog/v2"}, - {"feed_id", gen_uuid(m_server_id + "/categories")}, + {"feed_id", gen_uuid(m_library_id + "/categories")}, {"categories", categoryData } }, "application/atom+xml;profile=opds-catalog;kind=navigation" diff --git a/src/server/internalServer.h b/src/server/internalServer.h index d57ac6ed9..af28856f0 100644 --- a/src/server/internalServer.h +++ b/src/server/internalServer.h @@ -107,6 +107,7 @@ class InternalServer { NameMapper* mp_nameMapper; std::string m_server_id; + std::string m_library_id; friend std::unique_ptr Response::build(const InternalServer& server); friend std::unique_ptr ContentResponse::build(const InternalServer& server, const std::string& content, const std::string& mimetype, bool isHomePage);