From 111aab0c23222e15e32a813c7d84b9dd9966d7e7 Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Sun, 31 Jul 2022 15:24:59 +0400 Subject: [PATCH] Illustration URL uses the book UUID If the server is initialized with a library.xml file, then the id specified in the XML file is used (rather than the UUID recorded in the ZIM file). Note that in test/data/library.xml the book ids are fake and different from the real ZIM IDs; that file was created for testing of the /catalog endpoint which doesn't access ZIM content, so the the same ZIM file zimfile.zim was added to library.xml three times as three different books (with unique human-friendly ids). This explains the diff in test/library_server.cpp. --- src/server/internalServer_catalog_v2.cpp | 3 +-- static/templates/catalog_v2_entry.xml | 2 +- test/library_server.cpp | 2 +- test/server.cpp | 5 +++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/server/internalServer_catalog_v2.cpp b/src/server/internalServer_catalog_v2.cpp index 79504e5de..48d747ba0 100644 --- a/src/server/internalServer_catalog_v2.cpp +++ b/src/server/internalServer_catalog_v2.cpp @@ -154,8 +154,7 @@ std::unique_ptr InternalServer::handle_catalog_v2_languages(const Requ std::unique_ptr InternalServer::handle_catalog_v2_illustration(const RequestContext& request) { try { - const auto bookName = request.get_url_part(3); - const auto bookId = mp_nameMapper->getIdForName(bookName); + const auto bookId = request.get_url_part(3); auto book = mp_library->getBookByIdThreadSafe(bookId); auto size = request.get_argument("size"); auto illustration = book.getIllustration(size); diff --git a/static/templates/catalog_v2_entry.xml b/static/templates/catalog_v2_entry.xml index a2526b29f..b572da69c 100644 --- a/static/templates/catalog_v2_entry.xml +++ b/static/templates/catalog_v2_entry.xml @@ -16,7 +16,7 @@ {{article_count}} {{media_count}} {{#icons}} {{/icons}} diff --git a/test/library_server.cpp b/test/library_server.cpp index 3f430c6a3..e6119dafb 100644 --- a/test/library_server.cpp +++ b/test/library_server.cpp @@ -108,7 +108,7 @@ std::string maskVariableOPDSFeedData(std::string s) " 284\n" \ " 2\n" \ " \n" \ " \n" \ " \n" \ diff --git a/test/server.cpp b/test/server.cpp index 24b46a828..034a398cb 100644 --- a/test/server.cpp +++ b/test/server.cpp @@ -72,7 +72,7 @@ const ResourceCollection resources200Uncompressible{ { WITH_ETAG, "/ROOT/raw/zimfile/meta/Creator" }, { WITH_ETAG, "/ROOT/raw/zimfile/meta/Publisher" }, - { NO_ETAG, "/ROOT/catalog/v2/illustration/zimfile?size=48" }, + { NO_ETAG, "/ROOT/catalog/v2/illustration/6f1d19d0-633f-087b-fb55-7ac324ff9baf?size=48" }, { WITH_ETAG, "/ROOT/zimfile/I/m/Ray_Charles_classic_piano_pose.jpg" }, @@ -253,7 +253,8 @@ const char* urls404[] = { "/ROOT/catalog", "/ROOT/catalog/non-existent-item", "/ROOT/catalogBLABLABLA/root.xml", - "/ROOT/catalog/v2/illustration/zimfile?size=96", + "/ROOT/catalog/v2/illustration/zimfile?size=48", + "/ROOT/catalog/v2/illustration/6f1d19d0-633f-087b-fb55-7ac324ff9baf?size=96", "/ROOT/meta", "/ROOT/meta?content=zimfile", "/ROOT/meta?content=zimfile&name=non-existent-item",