Kelson has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/79021 )
Change subject: Bug Fix for bug no 52324 on openzim. Sorts the MIME Types before storing them to file. ...................................................................... Bug Fix for bug no 52324 on openzim. Sorts the MIME Types before storing them to file. Since this will be the new standard, the old ZIM files will have to be generated gain in order to obtain checksum match during zimdiff/zimpatch Change-Id: I37a32d4d9adad7402ab7dbb0d9bee143b76d89b7 --- M zimlib/include/zim/dirent.h M zimlib/src/zimcreator.cpp 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/zimlib/include/zim/dirent.h b/zimlib/include/zim/dirent.h index a5e0511..2ceea35 100644 --- a/zimlib/include/zim/dirent.h +++ b/zimlib/include/zim/dirent.h @@ -108,7 +108,10 @@ clusterNumber = 0; blobNumber = 0; } - + void setMimeType(uint16_t mime) + { + mimeType=mime; + } void setLinktarget() { mimeType = linktargetMimeType; diff --git a/zimlib/src/zimcreator.cpp b/zimlib/src/zimcreator.cpp index bbc9420..e767dd3 100644 --- a/zimlib/src/zimcreator.cpp +++ b/zimlib/src/zimcreator.cpp @@ -401,12 +401,40 @@ log_debug("after writing header - pos=" << zimfile.tellp()); // write mime type list + std::vector <std::string> oldMImeList; + std::vector <std::string> newMImeList; + std::vector<uint16_t>mapping; + for (RMimeTypes::const_iterator it = rmimeTypes.begin(); it != rmimeTypes.end(); ++it) + { + oldMImeList.push_back(it->second); + newMImeList.push_back(it->second); + } + mapping.resize(oldMImeList.size()); + std::sort(newMImeList.begin(),newMImeList.end()); + for(unsigned int i=0;i<oldMImeList.size();i++) + { + for(unsigned int j=0;j<newMImeList.size();j++) + { + if(oldMImeList[i]==newMImeList[j]) + mapping[i]=(uint16_t)j; + } + } + for (unsigned int i=0;i<dirents.size();i++) + { + dirents[i].setMimeType((uint16_t)mapping[dirents[i].getMimeType()]); + } + + for(unsigned int i=0;i<newMImeList.size();i++) + { + out<<newMImeList[i]<<'\0'; + } + /* for (RMimeTypes::const_iterator it = rmimeTypes.begin(); it != rmimeTypes.end(); ++it) { out << it->second << '\0'; } - + */ out << '\0'; // write url ptr list -- To view, visit https://gerrit.wikimedia.org/r/79021 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I37a32d4d9adad7402ab7dbb0d9bee143b76d89b7 Gerrit-PatchSet: 1 Gerrit-Project: openzim Gerrit-Branch: master Gerrit-Owner: Kiran mathew koshy 1993 <kiranmathewko...@gmail.com> Gerrit-Reviewer: Kelson <kel...@kiwix.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits