From 1dd828e79cb790b9d3b9d70fb400410a3332abc5 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Wed, 18 Apr 2018 15:39:08 +0200 Subject: [PATCH] Fix pathExists and check for correct path for xapian index. The correct path for xapian database should be "X/fulltext/xapian", not "Z//fulltextIndex/xapian". So lets check for the right path and fallback to the wrong one (but used in old zims). The double '/' in the path is a bug of zimwriterfs and is specific to the xapian database. We must handle this correctly in `hasFulltextIndex` and not (buggly) in `pathExists`. (Hopefully, it seems that pathExists were used only by hasFulltextIndex) --- src/reader.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/reader.cpp b/src/reader.cpp index 0103366be..ccbede73c 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -647,10 +647,14 @@ bool Reader::urlExists(const string& url) const bool Reader::pathExists(const string& path) const { + if (!zimFileHandler) + { + return false; + } + char ns = 0; string titleStr; _parseUrl(path, &ns, titleStr); - titleStr = "/" + titleStr; zim::File::const_iterator findItr = zimFileHandler->find(ns, titleStr); return findItr != zimFileHandler->end() && findItr->getUrl() == titleStr; } @@ -658,8 +662,13 @@ bool Reader::pathExists(const string& path) const /* Does the ZIM file has a fulltext index */ bool Reader::hasFulltextIndex() const { - return ( this->pathExists("/Z/fulltextIndex/xapian") - && !zimFileHandler->is_multiPart() ); + if (!zimFileHandler || zimFileHandler->is_multiPart() ) + { + return false; + } + + return ( pathExists("Z//fulltextIndex/xapian") + || pathExists("X/fulltext/xapian")); } /* Search titles by prefix */