Thread safe dumping of the OPDS feed

This commit is contained in:
Veloman Yunkan 2021-11-28 19:53:48 +04:00
parent 473d2d2a69
commit ad2eb52553
1 changed files with 9 additions and 4 deletions

View File

@ -108,10 +108,15 @@ BooksData getBooksData(const Library* library, const std::vector<std::string>& b
{ {
BooksData booksData; BooksData booksData;
for ( const auto& bookId : bookIds ) { for ( const auto& bookId : bookIds ) {
const Book& book = library->getBookById(bookId); try {
booksData.push_back(kainjow::mustache::object{ const Book book = library->getBookByIdThreadSafe(bookId);
{"entry", getSingleBookEntryXML(book, false, endpointRoot, partial)} booksData.push_back(kainjow::mustache::object{
}); {"entry", getSingleBookEntryXML(book, false, endpointRoot, partial)}
});
} catch ( const std::out_of_range& ) {
// the book was removed from the library since its id was obtained
// ignore it
}
} }
return booksData; return booksData;