mirror of
https://github.com/kiwix/kiwix-tools.git
synced 2025-09-22 11:22:38 -04:00
Merge pull request #633 from kiwix/adapt_libkiwix_991
This commit is contained in:
commit
3a0e87d8ea
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@ -14,10 +14,10 @@ jobs:
|
|||||||
- win32_dyn
|
- win32_dyn
|
||||||
include:
|
include:
|
||||||
- target: native_static
|
- target: native_static
|
||||||
image_variant: bionic
|
image_variant: focal
|
||||||
lib_postfix: '/x86_64-linux-gnu'
|
lib_postfix: '/x86_64-linux-gnu'
|
||||||
- target: native_dyn
|
- target: native_dyn
|
||||||
image_variant: bionic
|
image_variant: focal
|
||||||
lib_postfix: '/x86_64-linux-gnu'
|
lib_postfix: '/x86_64-linux-gnu'
|
||||||
- target: win32_static
|
- target: win32_static
|
||||||
image_variant: f35
|
image_variant: f35
|
||||||
|
9
.github/workflows/package.yml
vendored
9
.github/workflows/package.yml
vendored
@ -8,7 +8,6 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
distro:
|
distro:
|
||||||
- ubuntu-kinetic
|
|
||||||
- ubuntu-jammy
|
- ubuntu-jammy
|
||||||
- ubuntu-focal
|
- ubuntu-focal
|
||||||
steps:
|
steps:
|
||||||
@ -41,14 +40,6 @@ jobs:
|
|||||||
args: --no-sign
|
args: --no-sign
|
||||||
ppa: ${{ steps.ppa.outputs.ppa }}
|
ppa: ${{ steps.ppa.outputs.ppa }}
|
||||||
|
|
||||||
- uses: legoktm/gh-action-build-deb@ubuntu-kinetic
|
|
||||||
if: matrix.distro == 'ubuntu-kinetic'
|
|
||||||
name: Build package for ubuntu-kinetic
|
|
||||||
id: build-ubuntu-kinetic
|
|
||||||
with:
|
|
||||||
args: --no-sign
|
|
||||||
ppa: ${{ steps.ppa.outputs.ppa }}
|
|
||||||
|
|
||||||
- uses: legoktm/gh-action-build-deb@ubuntu-focal
|
- uses: legoktm/gh-action-build-deb@ubuntu-focal
|
||||||
if: matrix.distro == 'ubuntu-focal'
|
if: matrix.distro == 'ubuntu-focal'
|
||||||
name: Build package for ubuntu-focal
|
name: Build package for ubuntu-focal
|
||||||
|
@ -29,10 +29,10 @@ using namespace std;
|
|||||||
|
|
||||||
enum supportedAction { NONE, ADD, SHOW, REMOVE };
|
enum supportedAction { NONE, ADD, SHOW, REMOVE };
|
||||||
|
|
||||||
void show(kiwix::Library* library, const std::string& bookId)
|
void show(const kiwix::Library& library, const std::string& bookId)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
auto& book = library->getBookById(bookId);
|
auto& book = library.getBookById(bookId);
|
||||||
std::cout << "id:\t\t" << book.getId() << std::endl
|
std::cout << "id:\t\t" << book.getId() << std::endl
|
||||||
<< "path:\t\t" << book.getPath() << std::endl
|
<< "path:\t\t" << book.getPath() << std::endl
|
||||||
<< "url:\t\t" << book.getUrl() << std::endl
|
<< "url:\t\t" << book.getUrl() << std::endl
|
||||||
@ -96,7 +96,7 @@ void usage()
|
|||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
int handle_show(kiwix::Library* library, const std::string& libraryPath,
|
int handle_show(const kiwix::Library& library, const std::string& libraryPath,
|
||||||
int argc, char* argv[])
|
int argc, char* argv[])
|
||||||
{
|
{
|
||||||
if (argc > 3 ) {
|
if (argc > 3 ) {
|
||||||
@ -105,7 +105,7 @@ int handle_show(kiwix::Library* library, const std::string& libraryPath,
|
|||||||
show(library, bookId);
|
show(library, bookId);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto booksIds = library->getBooksIds();
|
auto booksIds = library.getBooksIds();
|
||||||
for(auto& bookId: booksIds) {
|
for(auto& bookId: booksIds) {
|
||||||
show(library, bookId);
|
show(library, bookId);
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ int handle_show(kiwix::Library* library, const std::string& libraryPath,
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int handle_add(kiwix::Library* library, const std::string& libraryPath,
|
int handle_add(kiwix::LibraryPtr library, const std::string& libraryPath,
|
||||||
int argc, char* argv[])
|
int argc, char* argv[])
|
||||||
{
|
{
|
||||||
string zimPath;
|
string zimPath;
|
||||||
@ -182,11 +182,11 @@ int handle_add(kiwix::Library* library, const std::string& libraryPath,
|
|||||||
return(resultCode);
|
return(resultCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
int handle_remove(kiwix::Library* library, const std::string& libraryPath,
|
int handle_remove(kiwix::Library& library, const std::string& libraryPath,
|
||||||
int argc, char* argv[])
|
int argc, char* argv[])
|
||||||
{
|
{
|
||||||
std::string bookId;
|
std::string bookId;
|
||||||
const unsigned int totalBookCount = library->getBookCount(true, true);
|
const unsigned int totalBookCount = library.getBookCount(true, true);
|
||||||
int exitCode = 0;
|
int exitCode = 0;
|
||||||
|
|
||||||
if (argc <= 3) {
|
if (argc <= 3) {
|
||||||
@ -203,7 +203,7 @@ int handle_remove(kiwix::Library* library, const std::string& libraryPath,
|
|||||||
for (int i = 3; i<argc; i++) {
|
for (int i = 3; i<argc; i++) {
|
||||||
bookId = argv[i];
|
bookId = argv[i];
|
||||||
|
|
||||||
if (!library->removeBookById(bookId)) {
|
if (!library.removeBookById(bookId)) {
|
||||||
std::cerr << "Invalid book id '" << bookId << "'." << std::endl;
|
std::cerr << "Invalid book id '" << bookId << "'." << std::endl;
|
||||||
exitCode = 1;
|
exitCode = 1;
|
||||||
}
|
}
|
||||||
@ -216,7 +216,7 @@ int main(int argc, char** argv)
|
|||||||
{
|
{
|
||||||
string libraryPath = "";
|
string libraryPath = "";
|
||||||
supportedAction action = NONE;
|
supportedAction action = NONE;
|
||||||
kiwix::Library library;
|
auto library = kiwix::Library::create();
|
||||||
|
|
||||||
/* General argument parsing */
|
/* General argument parsing */
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
@ -261,7 +261,7 @@ int main(int argc, char** argv)
|
|||||||
libraryPath = kiwix::isRelativePath(libraryPath)
|
libraryPath = kiwix::isRelativePath(libraryPath)
|
||||||
? kiwix::computeAbsolutePath(kiwix::getCurrentDirectory(), libraryPath)
|
? kiwix::computeAbsolutePath(kiwix::getCurrentDirectory(), libraryPath)
|
||||||
: libraryPath;
|
: libraryPath;
|
||||||
kiwix::Manager manager(&library);
|
kiwix::Manager manager(library);
|
||||||
if (!manager.readFile(libraryPath, false)) {
|
if (!manager.readFile(libraryPath, false)) {
|
||||||
if (kiwix::fileExists(libraryPath) || action!=ADD) {
|
if (kiwix::fileExists(libraryPath) || action!=ADD) {
|
||||||
std::cerr << "Cannot read the library " << libraryPath << std::endl;
|
std::cerr << "Cannot read the library " << libraryPath << std::endl;
|
||||||
@ -273,13 +273,13 @@ int main(int argc, char** argv)
|
|||||||
int exitCode = 0;
|
int exitCode = 0;
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case SHOW:
|
case SHOW:
|
||||||
exitCode = handle_show(&library, libraryPath, argc, argv);
|
exitCode = handle_show(*library, libraryPath, argc, argv);
|
||||||
break;
|
break;
|
||||||
case ADD:
|
case ADD:
|
||||||
exitCode = handle_add(&library, libraryPath, argc, argv);
|
exitCode = handle_add(library, libraryPath, argc, argv);
|
||||||
break;
|
break;
|
||||||
case REMOVE:
|
case REMOVE:
|
||||||
exitCode = handle_remove(&library, libraryPath, argc, argv);
|
exitCode = handle_remove(*library, libraryPath, argc, argv);
|
||||||
break;
|
break;
|
||||||
case NONE:
|
case NONE:
|
||||||
break;
|
break;
|
||||||
@ -292,7 +292,7 @@ int main(int argc, char** argv)
|
|||||||
/* Rewrite the library file */
|
/* Rewrite the library file */
|
||||||
if (action == REMOVE || action == ADD) {
|
if (action == REMOVE || action == ADD) {
|
||||||
// writeToFile return true (1) if everything is ok => exitCode is 0
|
// writeToFile return true (1) if everything is ok => exitCode is 0
|
||||||
if (!library.writeToFile(libraryPath)) {
|
if (!library->writeToFile(libraryPath)) {
|
||||||
std::cerr << "Cannot write the library " << libraryPath << std::endl;
|
std::cerr << "Cannot write the library " << libraryPath << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ int main(int argc, char** argv)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string rootLocation = "/";
|
std::string rootLocation = "/";
|
||||||
kiwix::Library library;
|
auto library = kiwix::Library::create();
|
||||||
unsigned int nb_threads = DEFAULT_THREADS;
|
unsigned int nb_threads = DEFAULT_THREADS;
|
||||||
std::vector<std::string> zimPathes;
|
std::vector<std::string> zimPathes;
|
||||||
std::string libraryPath;
|
std::string libraryPath;
|
||||||
@ -331,7 +331,7 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Setup the library manager and get the list of books */
|
/* Setup the library manager and get the list of books */
|
||||||
kiwix::Manager manager(&library);
|
kiwix::Manager manager(library);
|
||||||
std::vector<std::string> libraryPaths;
|
std::vector<std::string> libraryPaths;
|
||||||
if (libraryFlag) {
|
if (libraryFlag) {
|
||||||
libraryPaths = kiwix::split(libraryPath, ";");
|
libraryPaths = kiwix::split(libraryPath, ";");
|
||||||
@ -340,7 +340,7 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check if the library is not empty (or only remote books)*/
|
/* Check if the library is not empty (or only remote books)*/
|
||||||
if (library.getBookCount(true, false) == 0) {
|
if (library->getBookCount(true, false) == 0) {
|
||||||
std::cerr << "The XML library file '" << libraryPath
|
std::cerr << "The XML library file '" << libraryPath
|
||||||
<< "' is empty (or has only remote books)." << std::endl;
|
<< "' is empty (or has only remote books)." << std::endl;
|
||||||
}
|
}
|
||||||
@ -376,8 +376,8 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
kiwix::UpdatableNameMapper nameMapper(library, noDateAliasesFlag);
|
auto nameMapper = std::make_shared<kiwix::UpdatableNameMapper>(library, noDateAliasesFlag);
|
||||||
kiwix::Server server(&library, &nameMapper);
|
kiwix::Server server(library, nameMapper);
|
||||||
|
|
||||||
if (!customIndexPath.empty()) {
|
if (!customIndexPath.empty()) {
|
||||||
try {
|
try {
|
||||||
@ -447,7 +447,7 @@ int main(int argc, char** argv)
|
|||||||
if ( libraryMustBeReloaded && !libraryPaths.empty() ) {
|
if ( libraryMustBeReloaded && !libraryPaths.empty() ) {
|
||||||
libraryFileTimestamp = curLibraryFileTimestamp;
|
libraryFileTimestamp = curLibraryFileTimestamp;
|
||||||
reloadLibrary(manager, libraryPaths);
|
reloadLibrary(manager, libraryPaths);
|
||||||
nameMapper.update();
|
nameMapper->update();
|
||||||
libraryMustBeReloaded = false;
|
libraryMustBeReloaded = false;
|
||||||
}
|
}
|
||||||
} while (waiting);
|
} while (waiting);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user