Fixed thumbnail display for books being downloaded

This commit is contained in:
Veloman Yunkan 2024-05-02 11:31:23 +02:00
parent 423f3e8d02
commit e12715e6c4

View File

@ -394,18 +394,25 @@ QVariant getBookAttribute(const kiwix::Book& b, const QString& a)
ContentManager::BookInfo ContentManager::getBookInfos(QString id, const QStringList &keys)
{
BookInfo values;
const kiwix::Book* b = [=]()->const kiwix::Book* {
const kiwix::Book* b = nullptr;
try {
return &mp_library->getBookById(id);
} catch (...) {
b = &mp_library->getBookById(id);
if ( ! b->getDownloadId().empty() ) {
// The book is still being downloaded and has been entered into the
// local library for technical reasons only. Get the book info from
// the remote library.
b = nullptr;
}
} catch (...) {}
if ( !b ) {
try {
QMutexLocker locker(&remoteLibraryLocker);
return &mp_remoteLibrary->getBookById(id.toStdString());
} catch(...) { return nullptr; }
b = &mp_remoteLibrary->getBookById(id.toStdString());
} catch(...) {}
}
}();
BookInfo values;
for(auto& key: keys){
values.insert(key, b ? getBookAttribute(*b, key) : "");
}