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:
cottongin
2026-02-15 19:53:52 -05:00
parent 19004eefaa
commit 66f703df69
5 changed files with 16 additions and 5 deletions

View File

@@ -570,10 +570,6 @@ bool Epub::generateThumbBmp(int height) const {
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;
}

View File

@@ -38,6 +38,15 @@ void RecentBooksStore::addBook(const std::string& path, const std::string& title
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,
const std::string& coverBmpPath) {
auto it =

View File

@@ -30,6 +30,9 @@ class RecentBooksStore {
void updateBook(const std::string& path, const std::string& title, const std::string& author,
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)
const std::vector<RecentBook>& getBooks() const { return recentBooks; }

View File

@@ -88,7 +88,7 @@ void HomeActivity::loadRecentCovers(int coverHeight) {
}
// 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);
PlaceholderCoverGenerator::generate(coverPath, book.title, book.author, thumbWidth, coverHeight);
}

View File

@@ -745,6 +745,9 @@ void EpubReaderActivity::onReaderMenuConfirm(EpubReaderMenuActivity::MenuAction
epub->setupCacheDir();
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);
// Defer go home to avoid race condition with display task