fix: prune books missing form sd card in recent books list (#1959)

This commit is contained in:
KemoNine
2026-05-16 22:03:49 +03:00
committed by GitHub
parent a3e51f9b1e
commit 93e81daf41
4 changed files with 26 additions and 14 deletions
+7 -13
View File
@@ -15,23 +15,17 @@ namespace {
constexpr unsigned long GO_HOME_MS = 1000;
} // namespace
void RecentBooksActivity::loadRecentBooks() {
recentBooks.clear();
const auto& books = RECENT_BOOKS.getBooks();
recentBooks.reserve(books.size());
for (const auto& book : books) {
// Skip if file no longer exists
if (!Storage.exists(book.path.c_str())) {
continue;
}
recentBooks.push_back(book);
}
}
void RecentBooksActivity::loadRecentBooks() { recentBooks = RECENT_BOOKS.getBooks(); }
void RecentBooksActivity::onEnter() {
Activity::onEnter();
// Prune entries whose backing files are gone; this is one of two interaction
// points where the persistent store gets cleaned (the other is addBook).
if (RECENT_BOOKS.pruneMissing()) {
RECENT_BOOKS.saveToFile();
}
// Load data
loadRecentBooks();