mirror of
https://github.com/kiwix/kiwix-tools.git
synced 2025-09-23 12:00:21 -04:00
Permanant fix for bug651.
Kiwix manager class is back to original state, additional function for obtaining origID has been added to Kiwix::Reader class. Kiwix-manage and Kiwix-serve back to normal.
This commit is contained in:
parent
b198e56717
commit
215ce29c1f
@ -24,45 +24,12 @@
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <pathTools.h>
|
||||
#include <zim/file.h>
|
||||
#include <kiwix/manager.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
enum supportedAction { NONE, ADD, SHOW, REMOVE };
|
||||
|
||||
inline char hi(char v)
|
||||
{
|
||||
char hex[] = "0123456789abcdef";
|
||||
return hex[(v >> 4) & 0xf];
|
||||
}
|
||||
|
||||
inline char lo(char v)
|
||||
{
|
||||
char hex[] = "0123456789abcdef";
|
||||
return hex[v & 0xf];
|
||||
}
|
||||
|
||||
std::string hexUUID (std::string in)
|
||||
{
|
||||
std::ostringstream out;
|
||||
for (unsigned n = 0; n < 4; ++n)
|
||||
out << hi(in[n]) << lo(in[n]);
|
||||
out << '-';
|
||||
for (unsigned n = 4; n < 6; ++n)
|
||||
out << hi(in[n]) << lo(in[n]);
|
||||
out << '-';
|
||||
for (unsigned n = 6; n < 8; ++n)
|
||||
out << hi(in[n]) << lo(in[n]);
|
||||
out << '-';
|
||||
for (unsigned n = 8; n < 10; ++n)
|
||||
out << hi(in[n]) << lo(in[n]);
|
||||
out << '-';
|
||||
for (unsigned n = 10; n < 16; ++n)
|
||||
out << hi(in[n]) << lo(in[n]);
|
||||
std::string op=out.str();
|
||||
return op;
|
||||
}
|
||||
|
||||
void show(kiwix::Library library) {
|
||||
std::vector<kiwix::Book>::iterator itr;
|
||||
@ -194,30 +161,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
if (zimPath != "") {
|
||||
zimPathToSave = zimPathToSave == "." ? zimPath : zimPathToSave;
|
||||
zim::File zimFile(zimPath);
|
||||
if(zimFile.getArticleByUrl("M/startfileuid").getIndex()!=std::numeric_limits<unsigned int>::max())
|
||||
{
|
||||
std::string id=zimFile.getArticleByUrl("M/endfileuid").getPage();
|
||||
std::string temp="";
|
||||
unsigned int k=0;
|
||||
char tempArray[16]="";
|
||||
for(unsigned int i=0; i<id.size(); i++)
|
||||
{
|
||||
if(id[i]=='\n')
|
||||
{
|
||||
tempArray[k]= atoi(temp.c_str());
|
||||
temp="";
|
||||
k++;
|
||||
}
|
||||
else
|
||||
{
|
||||
temp+=id[i];
|
||||
}
|
||||
}
|
||||
origID=hexUUID(tempArray);
|
||||
}
|
||||
//std::cout<<"\nORIGID: "<<origID;
|
||||
string bookId = libraryManager.addBookFromPathAndGetId(zimPath, zimPathToSave, url, false,origID);
|
||||
string bookId = libraryManager.addBookFromPathAndGetId(zimPath, zimPathToSave, url, false);
|
||||
|
||||
if (!bookId.empty()) {
|
||||
|
||||
|
@ -481,7 +481,7 @@ int main(int argc, char **argv) {
|
||||
cerr << "The XML library file '" << libraryPath << "' is empty (or has only remote books)." << endl;
|
||||
}
|
||||
} else {
|
||||
if (!libraryManager.addBookFromPath(zimPath, zimPath, "", false,"")) {
|
||||
if (!libraryManager.addBookFromPath(zimPath, zimPath, "", false)) {
|
||||
cerr << "Unable to add the ZIM file '" << zimPath << "' to the internal library." << endl;
|
||||
exit(1);
|
||||
} else if (!indexPath.empty()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user