Last modified: 2013-10-06 19:09:59 UTC
In all zim files, all articles that have a redirect are given the MIME type code of 65535. The problem is, whenever getMimeType() or getPage() is called in zimlib for an article that has a redirect, zimlib throws an "unknown MIME type 65535" error.
It works as expected. The mime type is explicitly set to std::numeric_limits<uint16_t>::max() in redirects. See include/zim/dirent.h line 104. Users should not call getMimeType or getPage on redirects but use isRedirect first to check weather the article is actually a redirect. The methods getMimeType and getPage do not actually make any sense on redirects. A improvement would be to change the error message to something more useful but calling getMimeType or getPage on redirects should throw an exception.
Yes, but throwing an error for every redirect article doesn't gain anything. getMimeType() could return "redirect" and getPage() could return an empty string, and that way, a throw and catch could be avoided.
A throw and catch could be avoided, if you just as for isRedirect first. It is just wrong to ask for a mime type or data from a redirect. "getMimeType()" should return a valid mime type and "redirect" is no mime type. Also a redirect has not empty page data. It has no page data at all since it does not make sense. It is just like in databases where there is a NULL value. It is an error if you ask for a value of a column, which do not have a value i.e. NULL.
Isn't it a little ironic that getLibraryMimeType() returns a 65535 without any error, but getMimeType() causes an error ?
Ok - bug accepted - getLibraryMimeType should throw an exception also.