diff --git a/src/common/kiwix/reader.cpp b/src/common/kiwix/reader.cpp index 030b6a6f9..8b063e16e 100644 --- a/src/common/kiwix/reader.cpp +++ b/src/common/kiwix/reader.cpp @@ -41,9 +41,18 @@ namespace kiwix { /* Constructor */ Reader::Reader(const string zimFilePath) : zimFileHandler(NULL) { + string tmpZimFilePath = zimFilePath; + + /* Remove potential trailing zimaa */ + size_t found = tmpZimFilePath.rfind("zimaa"); + if (found != string::npos && + tmpZimFilePath.size() > 5 && + found == tmpZimFilePath.size() - 5) { + tmpZimFilePath.resize(tmpZimFilePath.size() - 2); + } + + this->zimFileHandler = new zim::File(tmpZimFilePath); - this->zimFileHandler = new zim::File(zimFilePath); - if (this->zimFileHandler != NULL) { this->firstArticleOffset = this->zimFileHandler->getNamespaceBeginOffset('A'); this->lastArticleOffset = this->zimFileHandler->getNamespaceEndOffset('A');