Skip to content

Commit 45d0ec7

Browse files
committed
fixup! fixup! Introduce Manager::addBooksFromDirectory()
1 parent b1b85e8 commit 45d0ec7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/manager.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <filesystem>
2727
#include <iostream>
2828
#include <set>
29+
#include <queue>
2930

3031
namespace fs = std::filesystem;
3132

@@ -264,7 +265,7 @@ void Manager::addBooksFromDirectory(const std::string& path,
264265
dirQueue.push(fs::absolute(path).u8string());
265266
int totalBooksAdded = 0;
266267
if (verboseFlag)
267-
std::cout << "Starting BFS traversal at root directory: " << dirQueue.front() << std::endl;
268+
std::cout << "Adding books from the directory tree: " << dirQueue.front() << std::endl;
268269

269270
while (!dirQueue.empty()) {
270271
const auto currentPath = dirQueue.front();
@@ -282,13 +283,15 @@ void Manager::addBooksFromDirectory(const std::string& path,
282283
dirQueue.push(pathString);
283284
else if (verboseFlag)
284285
std::cout << "Already iterated over " << pathString << ". Skipping..." << std::endl;
285-
} else {
286+
} else if (resolvedPath.extension() == ".zim" || resolvedPath.extension() == ".zimaa") {
286287
if (!this->addBookFromPath(pathString, pathString, "", false)) {
287288
std::cerr << "Could not add " << pathString << " into the library." << std::endl;
288289
} else if (verboseFlag) {
289290
std::cout << "Added " << pathString << " into the library." << std::endl;
290291
totalBooksAdded++;
291292
}
293+
} else if (verboseFlag) {
294+
std::cout << "Skipped " << pathString << " - unsupported file type or permission denied." << std::endl;
292295
}
293296
}
294297
iteratedDirs.insert(currentPath);

0 commit comments

Comments
 (0)