And even more...

This commit is contained in:
jpirnay
2026-03-08 12:45:14 +01:00
parent 9182a05670
commit 98fb3d65c9
2 changed files with 19 additions and 10 deletions
+13 -6
View File
@@ -134,19 +134,26 @@ bool RecentBooksStore::loadFromBinaryFile() {
// load book to get missing data
RecentBook book = getDataFromBook(path);
if (book.title.empty() && book.author.empty() && version == 2) {
// Fall back to loading what we can from the store
std::string title, author;
if (!serialization::readString(inputFile, title) || !serialization::readString(inputFile, author)) {
if (version == 2) {
// v2 always stores title and author after path; consume them regardless
// of whether live metadata was found, to keep the stream aligned.
std::string storedTitle, storedAuthor;
if (!serialization::readString(inputFile, storedTitle) || !serialization::readString(inputFile, storedAuthor)) {
LOG_ERR("RBS", "Corrupt recent.bin: string too long at entry %u", i);
inputFile.close();
return false;
}
// Prefer live metadata; fall back to stored when live is unavailable.
const std::string& title = !book.title.empty() ? book.title : storedTitle;
const std::string& author = !book.title.empty() ? book.author : storedAuthor;
if (!title.empty()) {
tmpRecentBooks.push_back({path, title, author, "", ""});
}
} else if (!book.title.empty()) {
tmpRecentBooks.push_back(book);
} else {
// v1: no stored title/author bytes
if (!book.title.empty()) {
tmpRecentBooks.push_back(book);
}
}
}
recentBooks = std::move(tmpRecentBooks);