mirror of https://github.com/kiwix/libkiwix.git
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)
This commit is contained in:
parent
135028c16a
commit
1dd828e79c
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue