Merge pull request #517 from kiwix/fileExists

Change kiwix::fileExists to kiwix::fileReadable
This commit is contained in:
Kelson 2022-01-09 20:17:26 +01:00 committed by GitHub
commit d8ed915c80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -86,8 +86,8 @@ string loadCustomTemplate (string customIndexPath) {
customIndexPath = kiwix::isRelativePath(customIndexPath) ?
kiwix::computeAbsolutePath(kiwix::getCurrentDirectory(), customIndexPath) :
customIndexPath;
if (!kiwix::fileExists(customIndexPath)) {
throw runtime_error("No such file exist (or file is not readable)" + customIndexPath);
if (!kiwix::fileReadable(customIndexPath)) {
throw runtime_error("No such file exist (or file is not readable) " + customIndexPath);
}
if (kiwix::getMimeTypeForFile(customIndexPath) != "text/html") {
throw runtime_error("Invalid File Mime Type " + kiwix::getMimeTypeForFile(customIndexPath));