diff --git a/src/common/kiwix/reader.cpp b/src/common/kiwix/reader.cpp index a5d3b01ab..6b0e7e5fd 100644 --- a/src/common/kiwix/reader.cpp +++ b/src/common/kiwix/reader.cpp @@ -236,4 +236,22 @@ namespace kiwix { return retVal; } + + /* Check if the file has as checksum */ + bool Reader::canCheckIntegrity() { + return this->zimFileHandler->getChecksum() != ""; + } + + /* Return true if corrupted, false otherwise */ + bool Reader::isCorrupted() { + try { + if (this->zimFileHandler->verify() == true) + return false; + } catch (exception &e) { + cerr << e.what() << endl; + return true; + } + + return true; + } } diff --git a/src/common/kiwix/reader.h b/src/common/kiwix/reader.h index 017059303..242a69c00 100644 --- a/src/common/kiwix/reader.h +++ b/src/common/kiwix/reader.h @@ -29,6 +29,8 @@ namespace kiwix { bool getContentByUrl(const string &url, string &content, unsigned int &contentLength, string &contentType); bool searchSuggestions(const string &prefix, unsigned int suggestionsCount); bool getNextSuggestion(string &title); + bool canCheckIntegrity(); + bool isCorrupted(); protected: zim::File* zimFileHandler;