-
-
Notifications
You must be signed in to change notification settings - Fork 70
Introduce Manager::addBooksFromDirectory() #1220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
veloman-yunkan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The output of the verbose mode may be somewhat confusing in the context of the full log - the purpose of iterating over files and directories is not obvious. Maybe the output should start (and end) with the description of the operation being performed.
| else if (verboseFlag) | ||
| std::cout << "Already iterated over " << pathString << ". Skipping..." << std::endl; | ||
| } else { | ||
| if (!this->addBookFromPath(pathString, pathString, "", false)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Is it wise trying to treat all files (regardless of their extension) as ZIM?
- Shouldn't this operation also be reported in the verbose output?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
Probably not, and with the recent changes in 1baa142. This would report a std:cerrr for each non ZIM file. I will push a commit for it but wanted to ask if you've tackled this before? Should checking the extensions for .zim, .zimaa, .zimab (and their capitals) be sufficient?
-
Done in fixup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should checking the extensions for .zim, .zimaa, .zimab (and their capitals) be sufficient?
I think that you should go only after .zim and .zimaa files.
@kelson42 Please confirm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
100% agree with @veloman-yunkan, this is already what I said in my first review, see kiwix/kiwix-tools#743 (comment)
I tried improving them some. The caller would know the purpose though, wont they? |
src/manager.cpp
Outdated
| dirQueue.push(fs::absolute(path).u8string()); | ||
| int totalBooksAdded = 0; | ||
| if (verboseFlag) | ||
| std::cout << "Starting BFS traversal at root directory: " << dirQueue.front() << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer if the message reads "Adding books from the directory tree: /path/to/dir"
| else if (verboseFlag) | ||
| std::cout << "Already iterated over " << pathString << ". Skipping..." << std::endl; | ||
| } else { | ||
| if (!this->addBookFromPath(pathString, pathString, "", false)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should checking the extensions for .zim, .zimaa, .zimab (and their capitals) be sufficient?
I think that you should go only after .zim and .zimaa files.
@kelson42 Please confirm
kelson42
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to compile and test the code but for me it does not compile:
skin/i18n/tr.json ['skin', 'i18n', 'tr_json']
skin/i18n/zh-hans.json ['skin', 'i18n', 'zh_hans_json']
skin/i18n/zh-hant.json ['skin', 'i18n', 'zh_hant_json']
[14/81] Compiling C++ object src/libkiwix.so.14.0.0.p/manager.cpp.o
FAILED: src/libkiwix.so.14.0.0.p/manager.cpp.o
c++ -Isrc/libkiwix.so.14.0.0.p -Isrc -I../src -Iinclude -I../include -I/usr/include/kainjow -Istatic -I/usr/local/include -I/usr/include/x86_64-linux-gnu -I/usr/include/p11-kit-1 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Werror -std=c++17 -O0 -g -fPIC -pthread -MD -MQ src/libkiwix.so.14.0.0.p/manager.cpp.o -MF src/libkiwix.so.14.0.0.p/manager.cpp.o.d -o src/libkiwix.so.14.0.0.p/manager.cpp.o -c ../src/manager.cpp
../src/manager.cpp: In member function ‘void kiwix::Manager::addBooksFromDirectory(const std::string&, bool)’:
../src/manager.cpp:263:8: error: ‘queue’ is not a member of ‘std’
263 | std::queue<std::string> dirQueue;
| ^~~~~
../src/manager.cpp:28:1: note: ‘std::queue’ is defined in header ‘<queue>’; this is probably fixable by adding ‘#include <queue>’
27 | #include <iostream>
+++ |+#include <queue>
28 | #include <set>
../src/manager.cpp:263:25: error: expected primary-expression before ‘>’ token
263 | std::queue<std::string> dirQueue;
| ^
../src/manager.cpp:263:27: error: ‘dirQueue’ was not declared in this scope
263 | std::queue<std::string> dirQueue;
| ^~~~~~~~
[23/81] Compiling C++ object src/libkiwix.so.14.0.0.p/library.cpp.o
ninja: build stopped: subcommand failed.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1220 +/- ##
==========================================
- Coverage 42.87% 42.55% -0.33%
==========================================
Files 60 60
Lines 4744 4780 +36
Branches 2498 2527 +29
==========================================
Hits 2034 2034
- Misses 1088 1124 +36
Partials 1622 1622 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@juuz0 Thx, I guess the compilation error is foxed? I will gove a new run on saturday. |
|
@kelson42 Yes, it should be. I didn't face that and probably veloman either, but from your error logs it showed missing the queue header. I added that explicitly now. |
Yes, I use g++14 on Ubuntu 24.04. |
|
@juuz0 Thank you for the multiple fixes. It compiles fine now for me. At this stage:
|
|
@juuz0 Any news? I just rebase briefly. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Added a function to load books from a directory. Requires rootPath to iterate over.
skipInvalid=false makes little sense, if an invalid book is found, we can simply choose to ignore it rather stopping the whole operation midway.
Fixes kiwix/kiwix-tools#739
Pre-requirement for: kiwix/kiwix-tools#743
Added a function to load books from a directory. Requires rootPath to iterate over.