fix: Fix cover thumbnail pipeline for home screen
Remove empty sentinel BMP file from generateThumbBmp() that blocked placeholder generation for books without covers. Add removeBook() to RecentBooksStore and clear book from recents on cache delete. Ensure home screen always generates placeholder when thumbnail generation fails. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -570,10 +570,6 @@ bool Epub::generateThumbBmp(int height) const {
|
|||||||
LOG_ERR("EBP", "Cover image is not a supported format, skipping thumbnail");
|
LOG_ERR("EBP", "Cover image is not a supported format, skipping thumbnail");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write an empty bmp file to avoid generation attempts in the future
|
|
||||||
FsFile thumbBmp;
|
|
||||||
Storage.openFileForWrite("EBP", getThumbBmpPath(height), thumbBmp);
|
|
||||||
thumbBmp.close();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,15 @@ void RecentBooksStore::addBook(const std::string& path, const std::string& title
|
|||||||
saveToFile();
|
saveToFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RecentBooksStore::removeBook(const std::string& path) {
|
||||||
|
auto it =
|
||||||
|
std::find_if(recentBooks.begin(), recentBooks.end(), [&](const RecentBook& book) { return book.path == path; });
|
||||||
|
if (it != recentBooks.end()) {
|
||||||
|
recentBooks.erase(it);
|
||||||
|
saveToFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void RecentBooksStore::updateBook(const std::string& path, const std::string& title, const std::string& author,
|
void RecentBooksStore::updateBook(const std::string& path, const std::string& title, const std::string& author,
|
||||||
const std::string& coverBmpPath) {
|
const std::string& coverBmpPath) {
|
||||||
auto it =
|
auto it =
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ class RecentBooksStore {
|
|||||||
void updateBook(const std::string& path, const std::string& title, const std::string& author,
|
void updateBook(const std::string& path, const std::string& title, const std::string& author,
|
||||||
const std::string& coverBmpPath);
|
const std::string& coverBmpPath);
|
||||||
|
|
||||||
|
// Remove a book from the recent list by path
|
||||||
|
void removeBook(const std::string& path);
|
||||||
|
|
||||||
// Get the list of recent books (most recent first)
|
// Get the list of recent books (most recent first)
|
||||||
const std::vector<RecentBook>& getBooks() const { return recentBooks; }
|
const std::vector<RecentBook>& getBooks() const { return recentBooks; }
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ void HomeActivity::loadRecentCovers(int coverHeight) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fallback: generate a placeholder thumbnail with title/author
|
// Fallback: generate a placeholder thumbnail with title/author
|
||||||
if (!success && !Storage.exists(coverPath.c_str())) {
|
if (!success) {
|
||||||
const int thumbWidth = static_cast<int>(coverHeight * 0.6);
|
const int thumbWidth = static_cast<int>(coverHeight * 0.6);
|
||||||
PlaceholderCoverGenerator::generate(coverPath, book.title, book.author, thumbWidth, coverHeight);
|
PlaceholderCoverGenerator::generate(coverPath, book.title, book.author, thumbWidth, coverHeight);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -745,6 +745,9 @@ void EpubReaderActivity::onReaderMenuConfirm(EpubReaderMenuActivity::MenuAction
|
|||||||
epub->setupCacheDir();
|
epub->setupCacheDir();
|
||||||
|
|
||||||
saveProgress(backupSpine, backupPage, backupPageCount);
|
saveProgress(backupSpine, backupPage, backupPageCount);
|
||||||
|
|
||||||
|
// 5. Remove from recent books so the home screen doesn't show a stale/placeholder cover
|
||||||
|
RECENT_BOOKS.removeBook(epub->getPath());
|
||||||
}
|
}
|
||||||
xSemaphoreGive(renderingMutex);
|
xSemaphoreGive(renderingMutex);
|
||||||
// Defer go home to avoid race condition with display task
|
// Defer go home to avoid race condition with display task
|
||||||
|
|||||||
Reference in New Issue
Block a user