Review fixes

This commit is contained in:
jpirnay
2026-04-15 10:40:19 +02:00
parent 920b3c0b32
commit b0843fbbb2
5 changed files with 20 additions and 11 deletions
+1 -2
View File
@@ -83,7 +83,7 @@ class BookmarkStore {
return; return;
} }
if (bookmarks.size() > UINT16_MAX) { if (bookmarks.size() > MAX_BOOKMARKS) {
LOG_ERR("BKM", "Too many bookmarks to save: %u", static_cast<unsigned>(bookmarks.size())); LOG_ERR("BKM", "Too many bookmarks to save: %u", static_cast<unsigned>(bookmarks.size()));
return; return;
} }
@@ -109,7 +109,6 @@ class BookmarkStore {
} }
} }
bool closeOk = false;
if (ok) { if (ok) {
if (!f.close()) { if (!f.close()) {
LOG_ERR("BKM", "Failed to close bookmarks file"); LOG_ERR("BKM", "Failed to close bookmarks file");
+5 -1
View File
@@ -176,7 +176,11 @@ bool GlobalBookmarkIndex::reconcile() {
entries.erase(std::remove_if(entries.begin(), entries.end(), entries.erase(std::remove_if(entries.begin(), entries.end(),
[](const Entry& e) { [](const Entry& e) {
if (!Storage.exists(e.sourcePath.c_str())) { if (!Storage.exists(e.sourcePath.c_str())) {
LOG_DBG("GBI", "Dropping orphan entry: %s", e.sourcePath.c_str()); LOG_DBG("GBI", "Dropping orphan entry: missing sourcePath=%s", e.sourcePath.c_str());
return true;
}
if (!Storage.exists(e.cacheDir.c_str())) {
LOG_DBG("GBI", "Dropping orphan entry: missing cacheDir=%s", e.cacheDir.c_str());
return true; return true;
} }
return false; return false;
@@ -20,9 +20,7 @@
void GlobalBookmarksActivity::onEnter() { void GlobalBookmarksActivity::onEnter() {
Activity::onEnter(); Activity::onEnter();
if (GLOBAL_BOOKMARKS.reconcile()) { GLOBAL_BOOKMARKS.reconcile();
GLOBAL_BOOKMARKS.save();
}
rebuildRows(); rebuildRows();
const int first = firstSelectableIndex(); const int first = firstSelectableIndex();
+1 -1
View File
@@ -260,7 +260,7 @@ void HomeActivity::loop() {
if (firstRenderDone && !recentsLoaded && !recentsLoading) { if (firstRenderDone && !recentsLoaded && !recentsLoading) {
const auto& metrics = UITheme::getInstance().getMetrics(); const auto& metrics = UITheme::getInstance().getMetrics();
const Rect contentRect = UITheme::getContentRect(renderer, true, false); const Rect contentRect = UITheme::getContentRect(renderer, true, false);
const int menuItemCount = hasOpdsUrl ? 6 : 5; const int menuItemCount = getMenuItemCount();
const HomeScreenLayout layout = computeHomeScreenLayout(metrics, contentRect.height, menuItemCount); const HomeScreenLayout layout = computeHomeScreenLayout(metrics, contentRect.height, menuItemCount);
loadRecentCovers(getHomeCoverRenderHeight(layout)); loadRecentCovers(getHomeCoverRenderHeight(layout));
return; return;
+12 -4
View File
@@ -438,6 +438,8 @@ void TxtReaderActivity::applyPendingBookmarkJump() {
return; return;
} }
LOG_DBG("TRS", "Applying pending bookmark jump: page=%u", jump.pageNumber); LOG_DBG("TRS", "Applying pending bookmark jump: page=%u", jump.pageNumber);
bool persisted = false;
FsFile f; FsFile f;
if (Storage.openFileForWrite("TRS", txt->getCachePath() + "/progress.bin", f)) { if (Storage.openFileForWrite("TRS", txt->getCachePath() + "/progress.bin", f)) {
uint8_t data[6] = {0}; uint8_t data[6] = {0};
@@ -445,11 +447,17 @@ void TxtReaderActivity::applyPendingBookmarkJump() {
data[1] = (jump.pageNumber >> 8) & 0xFF; data[1] = (jump.pageNumber >> 8) & 0xFF;
// Offset bytes stay 0: loadProgress reads only the page, and the lazy // Offset bytes stay 0: loadProgress reads only the page, and the lazy
// initializeReader() rebuilds the page index on first render anyway. // initializeReader() rebuilds the page index on first render anyway.
f.write(data, 6); if (f.write(data, 6) == 6) {
f.close(); persisted = f.close();
} else {
f.close();
}
}
if (persisted) {
jump.clear();
APP_STATE.saveToFile();
} }
jump.clear();
APP_STATE.saveToFile();
} }
void TxtReaderActivity::loadProgress() { void TxtReaderActivity::loadProgress() {