diff --git a/src/manager/kiwix-manage.cpp b/src/manager/kiwix-manage.cpp index 2143ded8..8d3f1722 100644 --- a/src/manager/kiwix-manage.cpp +++ b/src/manager/kiwix-manage.cpp @@ -96,18 +96,18 @@ void usage() << std::endl; } -int handle_show(kiwix::ConstLibraryPtr library, const std::string& libraryPath, +int handle_show(const kiwix::Library& library, const std::string& libraryPath, int argc, char* argv[]) { if (argc > 3 ) { for(auto i=3; igetBooksIds(); + auto booksIds = library.getBooksIds(); for(auto& bookId: booksIds) { - show(*library, bookId); + show(library, bookId); } } return(0); @@ -182,11 +182,11 @@ int handle_add(kiwix::LibraryPtr library, const std::string& libraryPath, return(resultCode); } -int handle_remove(kiwix::LibraryPtr library, const std::string& libraryPath, +int handle_remove(kiwix::Library& library, const std::string& libraryPath, int argc, char* argv[]) { std::string bookId; - const unsigned int totalBookCount = library->getBookCount(true, true); + const unsigned int totalBookCount = library.getBookCount(true, true); int exitCode = 0; if (argc <= 3) { @@ -203,7 +203,7 @@ int handle_remove(kiwix::LibraryPtr library, const std::string& libraryPath, for (int i = 3; iremoveBookById(bookId)) { + if (!library.removeBookById(bookId)) { std::cerr << "Invalid book id '" << bookId << "'." << std::endl; exitCode = 1; } @@ -273,13 +273,13 @@ int main(int argc, char** argv) int exitCode = 0; switch (action) { case SHOW: - exitCode = handle_show(library, libraryPath, argc, argv); + exitCode = handle_show(*library, libraryPath, argc, argv); break; case ADD: exitCode = handle_add(library, libraryPath, argc, argv); break; case REMOVE: - exitCode = handle_remove(library, libraryPath, argc, argv); + exitCode = handle_remove(*library, libraryPath, argc, argv); break; case NONE: break; diff --git a/src/server/kiwix-serve.cpp b/src/server/kiwix-serve.cpp index 30e0129e..d50481b2 100644 --- a/src/server/kiwix-serve.cpp +++ b/src/server/kiwix-serve.cpp @@ -197,7 +197,7 @@ int main(int argc, char** argv) #endif std::string rootLocation = "/"; - kiwix::LibraryPtr library; + auto library = kiwix::Library::create(); unsigned int nb_threads = DEFAULT_THREADS; std::vector zimPathes; std::string libraryPath;