From 761d75f89a09e999bd5f68aefddff38ba149c765 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Wed, 25 Oct 2023 15:06:36 +0200 Subject: [PATCH 1/7] Make the DirentInfo copy constructible. --- src/writer/_dirent.h | 16 ++++++++++++++++ src/writer/tinyString.h | 8 +++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/writer/_dirent.h b/src/writer/_dirent.h index 702801391..d80136678 100644 --- a/src/writer/_dirent.h +++ b/src/writer/_dirent.h @@ -58,6 +58,7 @@ namespace zim ns(ns) {}; Redirect(Redirect&& r) = default; + Redirect(const Redirect& r) = default; ~Redirect() {}; TinyString targetPath; NS ns; @@ -96,6 +97,21 @@ namespace zim resolved(std::move(r)), tag(DirentInfo::RESOLVED) {} + DirentInfo(const DirentInfo& other): + tag(other.tag) + { + switch (tag) { + case DIRECT: + new(&direct) Direct(other.direct); + break; + case REDIRECT: + new(&redirect) Redirect(other.redirect); + break; + case RESOLVED: + new(&resolved) Resolved(other.resolved); + break; + } + } DirentInfo::Direct& getDirect() { ASSERT(tag, ==, DIRECT); return direct; diff --git a/src/writer/tinyString.h b/src/writer/tinyString.h index bb8bde9d6..b8be44eb9 100644 --- a/src/writer/tinyString.h +++ b/src/writer/tinyString.h @@ -48,7 +48,13 @@ namespace zim t.m_data = nullptr; t.m_size = 0; }; - TinyString(const TinyString& t) = delete; + TinyString(const TinyString& t) : + m_data(new char[(uint16_t)t.m_size]), + m_size(t.m_size) + { + std::memcpy(m_data, t.m_data, m_size); + } + ~TinyString() { if (m_data) { delete[] m_data; From 10be0536faa07744691255986dfecc405af86131 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Wed, 25 Oct 2023 15:11:23 +0200 Subject: [PATCH 2/7] Introduce `addClone` to creator. This allow user to add a new entry which is a `Clone` of a previously added one. The new entry is the "same" that the original one but for the path and title. --- include/zim/writer/creator.h | 30 ++++++++++++++++++++++++++++++ src/writer/_dirent.h | 3 +++ src/writer/creator.cpp | 24 ++++++++++++++++++++++++ src/writer/creatordata.h | 1 + src/writer/dirent.cpp | 11 +++++++++++ src/writer/direntPool.h | 9 +++++++++ 6 files changed, 78 insertions(+) diff --git a/include/zim/writer/creator.h b/include/zim/writer/creator.h index b2cad01dd..60d1c546f 100644 --- a/include/zim/writer/creator.h +++ b/include/zim/writer/creator.h @@ -195,6 +195,36 @@ namespace zim const std::string& targetpath, const Hints& hints = Hints()); + + /** + * Add a clone of a existing entry. + * + * The existing entry pointed by `targetPath` is cloned and updated with + * `path` and `title`. + * + * The clone entry will shared the same type (redirection or item) + * and namespace than `targetPath`. + * + * If the `targetPath` is a item, the new entry will be item pointing + * to the same data than `targetPath` item. (Not a redirection to `targetPath`). + * However, the cloned entry is not counted in the media type counter + * and it is not fulltext indexed (only title indexed). + * + * Hints can be given to influence creator handling (front article, ...) + * as it is done for redirection. + * + * @param path the path of the clone + * @param title the title of the clone + * @param targetPath the path of the cloned entry. + * @param hints hints associated to the clone. + */ + void addClone( + const std::string& path, + const std::string& title, + const std::string& targetPath, + const Hints& hints = Hints() + ); + /** * Finalize the zim creation. */ diff --git a/src/writer/_dirent.h b/src/writer/_dirent.h index d80136678..548ee80b6 100644 --- a/src/writer/_dirent.h +++ b/src/writer/_dirent.h @@ -169,6 +169,9 @@ namespace zim // Creator for a "redirection" dirent Dirent(NS ns, const std::string& path, const std::string& title, NS targetNs, const std::string& targetPath); + // Creator for a "clone" dirent. Reuse the namespace of the targeted Dirent. + Dirent(const std::string& path, const std::string& title, const Dirent& target); + // Creator for "temporary" dirent, used to search for dirent in container. // We use them in url ordered container so we only need to set the namespace and the path. // Other value are irrelevant. diff --git a/src/writer/creator.cpp b/src/writer/creator.cpp index 2441ef416..d38621624 100644 --- a/src/writer/creator.cpp +++ b/src/writer/creator.cpp @@ -206,6 +206,23 @@ namespace zim data->handle(dirent, hints); } + void Creator::addClone(const std::string& path, const std::string& title, const std::string& targetPath, const Hints& hints) + { + checkError(); + Dirent tmpDirent(NS::C, targetPath); + auto existing_dirent_it = data->dirents.find(&tmpDirent); + + if (existing_dirent_it == data->dirents.end()) { + std::ostringstream ss; + ss << "Impossible to clone C/" << targetPath << " to C/" << path << std::endl; + ss << "C/" << targetPath << " doesn't exist." << std::endl; + throw InvalidEntry(ss.str()); + } + + auto dirent = data->createCloneDirent(path, title, **existing_dirent_it); + data->handle(dirent, hints); + } + void Creator::finishZimCreation() { checkError(); @@ -598,6 +615,13 @@ namespace zim return dirent; } + Dirent* CreatorData::createCloneDirent(const std::string& path, const std::string& title, const Dirent& target) + { + auto dirent = pool.getCloneDirent(path, title, target); + addDirent(dirent); + return dirent; + } + Cluster* CreatorData::closeCluster(bool compressed) { Cluster *cluster; diff --git a/src/writer/creatordata.h b/src/writer/creatordata.h index f75d45d92..5f83ffb55 100644 --- a/src/writer/creatordata.h +++ b/src/writer/creatordata.h @@ -74,6 +74,7 @@ namespace zim Dirent* createDirent(NS ns, const std::string& path, const std::string& mimetype, const std::string& title); Dirent* createItemDirent(const Item* item); Dirent* createRedirectDirent(NS ns, const std::string& path, const std::string& title, NS targetNs, const std::string& targetPath); + Dirent* createCloneDirent(const std::string& path, const std::string& title, const Dirent& target); Cluster* closeCluster(bool compressed); void setEntryIndexes(); diff --git a/src/writer/dirent.cpp b/src/writer/dirent.cpp index 8b9990ec2..d83cd0b0c 100644 --- a/src/writer/dirent.cpp +++ b/src/writer/dirent.cpp @@ -72,6 +72,17 @@ Dirent::Dirent(NS ns, const std::string& path, const std::string& title, NS targ frontArticle(false) {} +Dirent::Dirent(const std::string& path, const std::string& title, const Dirent& target) + : pathTitle(path, title), + mimeType(target.mimeType), + idx(0), + info(target.info), + offset(0), + _ns(target._ns), + removed(false), + frontArticle(false) +{} + NS Dirent::getRedirectNs() const { return info.getRedirect().ns; } diff --git a/src/writer/direntPool.h b/src/writer/direntPool.h index 227fbb3ab..ee90f61a7 100644 --- a/src/writer/direntPool.h +++ b/src/writer/direntPool.h @@ -81,6 +81,15 @@ namespace zim new (dirent) Dirent(ns, path, title, targetNs, targetPath); return dirent; } + + Dirent* getCloneDirent(const std::string& path, const std::string& title, const Dirent& target) { + if (direntIndex == 0xFFFF) { + allocate_new_pool(); + } + auto dirent = pools.back() + direntIndex++; + new (dirent) Dirent(path, title, target); + return dirent; + } }; } } From 150d4ab9542ed4d5326ba6faf03bf4cfc55eca13 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Wed, 25 Oct 2023 15:14:39 +0200 Subject: [PATCH 3/7] Test that we correctly create zim file with clone entries. --- test/creator.cpp | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/test/creator.cpp b/test/creator.cpp index aacebedcd..d64990b33 100644 --- a/test/creator.cpp +++ b/test/creator.cpp @@ -185,11 +185,13 @@ TEST(ZimCreator, createZim) // Be sure that title order is not the same that url order item = std::make_shared("foo2", "AFoo", "Foo2Content"); creator.addItem(item); + creator.addClone("foo_bis", "The same Foo", "foo2"); creator.addMetadata("Title", "This is a title"); creator.addIllustration(48, "PNGBinaryContent48"); creator.addIllustration(96, "PNGBinaryContent96"); creator.setMainPath("foo"); - creator.addRedirection("foo3", "FooRedirection", "foo"); // No a front article. + creator.addRedirection("foo3", "FooRedirection", "foo"); // Not a front article. + creator.addClone("foo_ter", "The same redirection", "foo3", {{ zim::writer::FRONT_ARTICLE, true}}); // a clone of the previous redirect, but as a front article. creator.addRedirection("foo4", "FooRedirection", "NoExistant", {{zim::writer::FRONT_ARTICLE, true}}); // Invalid redirection, must be removed by creator creator.finishZimCreation(); @@ -200,7 +202,7 @@ TEST(ZimCreator, createZim) header.read(*reader); ASSERT_TRUE(header.hasMainPage()); #if defined(ENABLE_XAPIAN) - entry_index_type nb_entry = 12; // counter + 2*illustration + xapiantitleIndex + xapianfulltextIndex + foo + foo2 + foo3 + Title + mainPage + titleListIndexes*2 + entry_index_type nb_entry = 14; // counter + 2*illustration + xapiantitleIndex + xapianfulltextIndex + foo + foo2 + foo_bis + foo3 + foo_ter + Title + mainPage + titleListIndexes*2 int xapian_mimetype = 0; int listing_mimetype = 1; int png_mimetype = 2; @@ -208,7 +210,7 @@ TEST(ZimCreator, createZim) int plain_mimetype = 4; int plainutf8_mimetype = 5; #else - entry_index_type nb_entry = 10; // counter + 2*illustration + foo + foo2 + foo3 + Title + mainPage + titleListIndexes*2 + entry_index_type nb_entry = 12; // counter + 2*illustration + foo + foo_bis + foo2 + foo3 + foo_ter + Title + mainPage + titleListIndexes*2 int listing_mimetype = 0; int png_mimetype = 1; int html_mimetype = 2; @@ -235,6 +237,12 @@ TEST(ZimCreator, createZim) dirent = direntAccessor.getDirent(entry_index_t(direntIdx++)); test_redirect_dirent(dirent, 'C', "foo3", "FooRedirection", entry_index_t(0)); + dirent = direntAccessor.getDirent(entry_index_t(direntIdx++)); + test_article_dirent(dirent, 'C', "foo_bis", "The same Foo", html_mimetype, cluster_index_t(0), foo2BlobIndex); + + dirent = direntAccessor.getDirent(entry_index_t(direntIdx++)); + test_redirect_dirent(dirent, 'C', "foo_ter", "The same redirection", entry_index_t(0)); + dirent = direntAccessor.getDirent(entry_index_t(direntIdx++)); test_article_dirent(dirent, 'M', "Counter", None, plain_mimetype, cluster_index_t(0), None); auto counterBlobIndex = dirent->getBlobNumber(); @@ -297,7 +305,7 @@ TEST(ZimCreator, createZim) clusterOffset = offset_t(reader->read_uint(offset_t(clusterPtrPos + 8))); cluster = Cluster::read(*reader, clusterOffset); ASSERT_EQ(cluster->getCompression(), Cluster::Compression::None); - ASSERT_EQ(cluster->count(), blob_index_t(nb_entry-6)); // 6 entries are either compressed or redirections + ASSERT_EQ(cluster->count(), blob_index_t(nb_entry-8)); // 7 entries are either compressed or redirections + 1 entry is a clone of content ASSERT_EQ(header.getTitleIdxPos(), (clusterOffset+cluster->getBlobOffset(v0BlobIndex)).v); @@ -314,20 +322,23 @@ TEST(ZimCreator, createZim) 6, 0, 0, 0, 7, 0, 0, 0, 8, 0, 0, 0, - 9, 0, 0, 0 + 9, 0, 0, 0, + 10, 0, 0, 0, + 11, 0, 0, 0 #if defined(ENABLE_XAPIAN) - ,10, 0, 0, 0 - ,11, 0, 0, 0 + ,12, 0, 0, 0 + ,13, 0, 0, 0 #endif }; ASSERT_EQ(blob0Data, expectedBlob0Data); blob = cluster->getBlob(v1BlobIndex); - ASSERT_EQ(blob.size(), 2*sizeof(title_index_t)); + ASSERT_EQ(blob.size(), 3*sizeof(title_index_t)); std::vector blob1Data(blob.data(), blob.end()); std::vector expectedBlob1Data = { 1, 0, 0, 0, - 0, 0, 0, 0 + 0, 0, 0, 0, + 4, 0, 0, 0 // "The same redirection" is the 5th entry "by title order" }; ASSERT_EQ(blob1Data, expectedBlob1Data); From 14b2c5d578107687cb4351c7e77ba6ee24fde725 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Wed, 25 Oct 2023 15:15:20 +0200 Subject: [PATCH 4/7] Introduce `getBlobIndex`. This is use in zim-check to not count clone entries as duplicated entries. --- include/zim/item.h | 1 + src/item.cpp | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/zim/item.h b/include/zim/item.h index e66c00f42..b2d38d140 100644 --- a/include/zim/item.h +++ b/include/zim/item.h @@ -90,6 +90,7 @@ namespace zim #ifdef ZIM_PRIVATE cluster_index_type getClusterIndex() const; + blob_index_type getBlobIndex() const; #endif private: // functions diff --git a/src/item.cpp b/src/item.cpp index c224e60ff..931ba47e8 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -88,3 +88,8 @@ cluster_index_type Item::getClusterIndex() const { return m_dirent->getClusterNumber().v; } + +blob_index_type Item::getBlobIndex() const +{ + return m_dirent->getBlobNumber().v; +} From 3828fe382d101094874d7818772f13701cc6c990 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Fri, 3 Nov 2023 10:38:52 +0100 Subject: [PATCH 5/7] Introduce helper method `DirentPool::getDirentSlot` --- src/writer/direntPool.h | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/writer/direntPool.h b/src/writer/direntPool.h index ee90f61a7..e8caced8c 100644 --- a/src/writer/direntPool.h +++ b/src/writer/direntPool.h @@ -44,6 +44,14 @@ namespace zim delete [] (reinterpret_cast(pool)); } + /* Return a *NOT constructed* pointer to a dirent */ + Dirent* getDirentSlot() { + if (direntIndex == 0xFFFF) { + allocate_new_pool(); + } + auto dirent = pools.back() + direntIndex++; + return dirent; + } public: DirentPool() : @@ -65,28 +73,19 @@ namespace zim } Dirent* getClassicDirent(NS ns, const std::string& path, const std::string& title, uint16_t mimetype) { - if (direntIndex == 0xFFFF) { - allocate_new_pool(); - } - auto dirent = pools.back() + direntIndex++; + auto dirent = getDirentSlot(); new (dirent) Dirent(ns, path, title, mimetype); return dirent; } Dirent* getRedirectDirent(NS ns, const std::string& path, const std::string& title, NS targetNs, const std::string& targetPath) { - if (direntIndex == 0xFFFF) { - allocate_new_pool(); - } - auto dirent = pools.back() + direntIndex++; + auto dirent = getDirentSlot(); new (dirent) Dirent(ns, path, title, targetNs, targetPath); return dirent; } Dirent* getCloneDirent(const std::string& path, const std::string& title, const Dirent& target) { - if (direntIndex == 0xFFFF) { - allocate_new_pool(); - } - auto dirent = pools.back() + direntIndex++; + auto dirent = getDirentSlot(); new (dirent) Dirent(path, title, target); return dirent; } From e641da672d56eeb2ddbb987ea03d7ac78b204144 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Fri, 3 Nov 2023 10:46:18 +0100 Subject: [PATCH 6/7] Rename addClone to addAlias. --- include/zim/writer/creator.h | 16 ++++++++-------- src/writer/_dirent.h | 2 +- src/writer/creator.cpp | 10 +++++----- src/writer/creatordata.h | 2 +- src/writer/direntPool.h | 2 +- test/creator.cpp | 4 ++-- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/include/zim/writer/creator.h b/include/zim/writer/creator.h index 60d1c546f..a104e52e3 100644 --- a/include/zim/writer/creator.h +++ b/include/zim/writer/creator.h @@ -197,28 +197,28 @@ namespace zim /** - * Add a clone of a existing entry. + * Add a alias of a existing entry. * * The existing entry pointed by `targetPath` is cloned and updated with * `path` and `title`. * - * The clone entry will shared the same type (redirection or item) + * The alias entry will shared the same type (redirection or item) * and namespace than `targetPath`. * * If the `targetPath` is a item, the new entry will be item pointing * to the same data than `targetPath` item. (Not a redirection to `targetPath`). - * However, the cloned entry is not counted in the media type counter + * However, the alias entry is not counted in the media type counter * and it is not fulltext indexed (only title indexed). * * Hints can be given to influence creator handling (front article, ...) * as it is done for redirection. * - * @param path the path of the clone - * @param title the title of the clone - * @param targetPath the path of the cloned entry. - * @param hints hints associated to the clone. + * @param path the path of the alias + * @param title the title of the alias + * @param targetPath the path of the aliased entry. + * @param hints hints associated to the alias. */ - void addClone( + void addAlias( const std::string& path, const std::string& title, const std::string& targetPath, diff --git a/src/writer/_dirent.h b/src/writer/_dirent.h index 548ee80b6..2b75af4db 100644 --- a/src/writer/_dirent.h +++ b/src/writer/_dirent.h @@ -169,7 +169,7 @@ namespace zim // Creator for a "redirection" dirent Dirent(NS ns, const std::string& path, const std::string& title, NS targetNs, const std::string& targetPath); - // Creator for a "clone" dirent. Reuse the namespace of the targeted Dirent. + // Creator for a "alias" dirent. Reuse the namespace of the targeted Dirent. Dirent(const std::string& path, const std::string& title, const Dirent& target); // Creator for "temporary" dirent, used to search for dirent in container. diff --git a/src/writer/creator.cpp b/src/writer/creator.cpp index d38621624..127661e6d 100644 --- a/src/writer/creator.cpp +++ b/src/writer/creator.cpp @@ -206,7 +206,7 @@ namespace zim data->handle(dirent, hints); } - void Creator::addClone(const std::string& path, const std::string& title, const std::string& targetPath, const Hints& hints) + void Creator::addAlias(const std::string& path, const std::string& title, const std::string& targetPath, const Hints& hints) { checkError(); Dirent tmpDirent(NS::C, targetPath); @@ -214,12 +214,12 @@ namespace zim if (existing_dirent_it == data->dirents.end()) { std::ostringstream ss; - ss << "Impossible to clone C/" << targetPath << " to C/" << path << std::endl; + ss << "Impossible to alias C/" << targetPath << " as C/" << path << std::endl; ss << "C/" << targetPath << " doesn't exist." << std::endl; throw InvalidEntry(ss.str()); } - auto dirent = data->createCloneDirent(path, title, **existing_dirent_it); + auto dirent = data->createAliasDirent(path, title, **existing_dirent_it); data->handle(dirent, hints); } @@ -615,9 +615,9 @@ namespace zim return dirent; } - Dirent* CreatorData::createCloneDirent(const std::string& path, const std::string& title, const Dirent& target) + Dirent* CreatorData::createAliasDirent(const std::string& path, const std::string& title, const Dirent& target) { - auto dirent = pool.getCloneDirent(path, title, target); + auto dirent = pool.getAliasDirent(path, title, target); addDirent(dirent); return dirent; } diff --git a/src/writer/creatordata.h b/src/writer/creatordata.h index 5f83ffb55..7ff8cbcd3 100644 --- a/src/writer/creatordata.h +++ b/src/writer/creatordata.h @@ -74,7 +74,7 @@ namespace zim Dirent* createDirent(NS ns, const std::string& path, const std::string& mimetype, const std::string& title); Dirent* createItemDirent(const Item* item); Dirent* createRedirectDirent(NS ns, const std::string& path, const std::string& title, NS targetNs, const std::string& targetPath); - Dirent* createCloneDirent(const std::string& path, const std::string& title, const Dirent& target); + Dirent* createAliasDirent(const std::string& path, const std::string& title, const Dirent& target); Cluster* closeCluster(bool compressed); void setEntryIndexes(); diff --git a/src/writer/direntPool.h b/src/writer/direntPool.h index e8caced8c..8ee9fd2bf 100644 --- a/src/writer/direntPool.h +++ b/src/writer/direntPool.h @@ -84,7 +84,7 @@ namespace zim return dirent; } - Dirent* getCloneDirent(const std::string& path, const std::string& title, const Dirent& target) { + Dirent* getAliasDirent(const std::string& path, const std::string& title, const Dirent& target) { auto dirent = getDirentSlot(); new (dirent) Dirent(path, title, target); return dirent; diff --git a/test/creator.cpp b/test/creator.cpp index d64990b33..db13e8c12 100644 --- a/test/creator.cpp +++ b/test/creator.cpp @@ -185,13 +185,13 @@ TEST(ZimCreator, createZim) // Be sure that title order is not the same that url order item = std::make_shared("foo2", "AFoo", "Foo2Content"); creator.addItem(item); - creator.addClone("foo_bis", "The same Foo", "foo2"); + creator.addAlias("foo_bis", "The same Foo", "foo2"); creator.addMetadata("Title", "This is a title"); creator.addIllustration(48, "PNGBinaryContent48"); creator.addIllustration(96, "PNGBinaryContent96"); creator.setMainPath("foo"); creator.addRedirection("foo3", "FooRedirection", "foo"); // Not a front article. - creator.addClone("foo_ter", "The same redirection", "foo3", {{ zim::writer::FRONT_ARTICLE, true}}); // a clone of the previous redirect, but as a front article. + creator.addAlias("foo_ter", "The same redirection", "foo3", {{ zim::writer::FRONT_ARTICLE, true}}); // a clone of the previous redirect, but as a front article. creator.addRedirection("foo4", "FooRedirection", "NoExistant", {{zim::writer::FRONT_ARTICLE, true}}); // Invalid redirection, must be removed by creator creator.finishZimCreation(); From 9a59af5d4d69a0d58f905039f3ed97e2a121cc7b Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Fri, 17 Nov 2023 13:06:44 +0100 Subject: [PATCH 7/7] Test that alias are properlly (not) indexed. --- test/search.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/test/search.cpp b/test/search.cpp index 5e6093ec3..5873b831b 100644 --- a/test/search.cpp +++ b/test/search.cpp @@ -64,6 +64,7 @@ TEST(Search, indexFullPath) auto item = std::make_shared("testPath", "text/html", "Test Article", "This is a test article"); creator.addItem(item); + creator.addAlias("anotherPath", "Another Test Article", "testPath"); creator.setMainPath("testPath"); creator.addMetadata("Title", "Test zim"); @@ -76,9 +77,14 @@ TEST(Search, indexFullPath) auto search = searcher.search(query); ASSERT_NE(0, search.getEstimatedMatches()); - auto result = search.getResults(0, archive.getEntryCount()); - ASSERT_EQ(result.begin().getPath(), "testPath"); - ASSERT_EQ(result.begin().getDbData().substr(0, 2), "C/"); + auto results = search.getResults(0, archive.getEntryCount()); + + auto result = results.begin(); + ASSERT_EQ(result.getPath(), "testPath"); + ASSERT_EQ(result.getDbData().substr(0, 2), "C/"); + + result++; + ASSERT_EQ(result, results.end()); } TEST(Search, fulltextSnippet) @@ -118,6 +124,7 @@ TEST(Search, multiSearch) creator.addItem(std::make_shared("path2", "text/html", "Test Article001", "This is a test article. Super. temp0")); creator.addItem(std::make_shared("path3", "text/html", "Test Article2", "This is a test article. Super.")); creator.addItem(std::make_shared("path4", "text/html", "Test Article23", "This is a test article. bis.")); + creator.addAlias("path5", "Test Article5", "path0"); // Should not be fulltext indexed creator.setMainPath("path0"); creator.finishZimCreation(); @@ -133,7 +140,7 @@ TEST(Search, multiSearch) zim::Query query("test article"); auto search0 = searcher.search(query); - ASSERT_EQ(archive.getEntryCount(), (unsigned int)search0.getEstimatedMatches()); + ASSERT_EQ(5U, (unsigned int)search0.getEstimatedMatches()); auto result0 = search0.getResults(0, 2); ASSERT_EQ(result0.size(), 2); auto it0 = result0.begin();