3
0
Fork 0

+ few performance improvement

small_fixes
kelson42 14 years ago
parent 0bd8c57a23
commit a21667b4cc

@ -152,19 +152,14 @@ int main(int argc, char **argv) {
/* Copy the file to the data/content directory */ /* Copy the file to the data/content directory */
string newContentPath = computeAbsolutePath(dataContentPath, contentFilename); string newContentPath = computeAbsolutePath(dataContentPath, contentFilename);
if (!fileExists(newContentPath) || getFileSize(contentPath) != getFileSize(newContentPath)) {
copyFile(contentPath, newContentPath); copyFile(contentPath, newContentPath);
/* Add the file to the library.xml */
string libraryPath = computeAbsolutePath(dataLibraryPath, contentFilename + ".xml");
kiwix::Manager libraryManager;
if (libraryManager.addBookFromPath(newContentPath, "../content/" + contentFilename, "", false)) {
libraryManager.writeFile(libraryPath);
} else {
cerr << "Unable to build or save library file '" << libraryPath << "'" << endl;
} }
/* Index the file if necessary */ /* Index the file if necessary */
string indexPath = computeAbsolutePath(dataIndexPath, contentFilename + ".idx"); string indexFilename = contentFilename + ".idx";
string indexPath = computeAbsolutePath(dataIndexPath, indexFilename);
if (buildIndexFlag && !fileExists(indexPath)) {
kiwix::Indexer *indexer = NULL; kiwix::Indexer *indexer = NULL;
try { try {
if (backend == CLUCENE) { if (backend == CLUCENE) {
@ -186,5 +181,20 @@ int main(int argc, char **argv) {
} }
} }
/* Add the file to the library.xml */
kiwix::Manager libraryManager;
string libraryPath = computeAbsolutePath(dataLibraryPath, contentFilename + ".xml");
string bookId = libraryManager.addBookFromPathAndGetId(newContentPath, "../content/" + contentFilename, "", false);
if (!bookId.empty()) {
libraryManager.setCurrentBookId(bookId);
if (buildIndexFlag) {
libraryManager.setBookIndex(bookId, "../index/" + indexFilename, kiwix::XAPIAN);
}
libraryManager.writeFile(libraryPath);
} else {
cerr << "Unable to build or save library file '" << libraryPath << "'" << endl;
}
}
exit(0); exit(0);
} }

Loading…
Cancel
Save