mirror of https://github.com/kiwix/libkiwix.git
Cleanup after previous change
- Got rid of the continue statement - Renamed the function parameter - Fixed indentation
This commit is contained in:
parent
5b9daf0d9d
commit
181893d31a
|
@ -35,26 +35,24 @@ HumanReadableNameMapper::HumanReadableNameMapper(kiwix::Library& library, bool w
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto aliasName = replaceRegex(bookName, "", "_[[:digit:]]{4}-[[:digit:]]{2}$");
|
auto aliasName = replaceRegex(bookName, "", "_[[:digit:]]{4}-[[:digit:]]{2}$");
|
||||||
if (aliasName == bookName) {
|
if (aliasName != bookName) {
|
||||||
continue;
|
mapName(library, aliasName, bookId);
|
||||||
}
|
}
|
||||||
|
|
||||||
mapName(library, aliasName, bookId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HumanReadableNameMapper::mapName(const Library& library, std::string aliasName, std::string bookId) {
|
void HumanReadableNameMapper::mapName(const Library& library, std::string name, std::string bookId) {
|
||||||
if (m_nameToId.find(aliasName) == m_nameToId.end()) {
|
if (m_nameToId.find(name) == m_nameToId.end()) {
|
||||||
m_nameToId[aliasName] = bookId;
|
m_nameToId[name] = bookId;
|
||||||
} else {
|
} else {
|
||||||
const auto& currentBook = library.getBookById(bookId);
|
const auto& currentBook = library.getBookById(bookId);
|
||||||
auto alreadyPresentPath = library.getBookById(m_nameToId[aliasName]).getPath();
|
auto alreadyPresentPath = library.getBookById(m_nameToId[name]).getPath();
|
||||||
std::cerr << "Path collision: " << alreadyPresentPath
|
std::cerr << "Path collision: " << alreadyPresentPath
|
||||||
<< " and " << currentBook.getPath()
|
<< " and " << currentBook.getPath()
|
||||||
<< " can't share the same URL path '" << aliasName << "'."
|
<< " can't share the same URL path '" << name << "'."
|
||||||
<< " Therefore, only " << alreadyPresentPath
|
<< " Therefore, only " << alreadyPresentPath
|
||||||
<< " will be served." << std::endl;
|
<< " will be served." << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string HumanReadableNameMapper::getNameForId(const std::string& id) const {
|
std::string HumanReadableNameMapper::getNameForId(const std::string& id) const {
|
||||||
|
|
Loading…
Reference in New Issue