Do not store the favicon base64 encoded in the book.

The fact that the favicon is base64 encoded in a storage detail.
This commit is contained in:
Matthieu Gautier 2018-09-06 15:07:09 +02:00
parent c7f9218350
commit 57fbb98bca
2 changed files with 3 additions and 3 deletions

View File

@ -268,7 +268,7 @@ bool Library::writeToFile(const std::string& path) {
bookNode.append_attribute("publisher") = book.publisher().c_str();
if (!book.favicon().empty())
bookNode.append_attribute("favicon") = book.favicon().c_str();
bookNode.append_attribute("favicon") = base64_encode(book.favicon()).c_str();
if (!book.faviconMimeType().empty())
bookNode.append_attribute("faviconMimeType")

View File

@ -46,6 +46,7 @@ bool Manager::parseXmlDom(const pugi::xml_document& doc,
kiwix::Book book;
book.setReadOnly(readOnly);
book.setFavicon(base64_decode(bookNode.attribute("favicon").value());
book.setId(bookNode.attribute("id").value());
std::string path = bookNode.attribute("path").value();
if (isRelativePath(path)) {
@ -73,7 +74,6 @@ bool Manager::parseXmlDom(const pugi::xml_document& doc,
book.setArticleCount(strtoull(bookNode.attribute("articleCount").value(), 0, 0));
book.setMediaCount(strtoull(bookNode.attribute("mediaCount").value(), 0, 0));
book.setSize(strtoull(bookNode.attribute("size").value(), 0, 0));
book.setFavicon(bookNode.attribute("favicon").value());
book.setFaviconMimeType(bookNode.attribute("faviconMimeType").value());
/* Update the book properties with the new importer */
@ -135,7 +135,7 @@ bool Manager::parseOpdsDom(const pugi::xml_document& doc, const std::string& url
auto fileHandle = downloader.download(faviconUrl);
if (fileHandle.success) {
auto content = getFileContent(fileHandle.path);
book.setFavicon(base64_encode(content));
book.setFavicon(content);
book.setFaviconMimeType(linkNode.attribute("type").value());
} else {
std::cerr << "Cannot get favicon content from " << faviconUrl << std::endl;