Session cache option, zip conversion fix, page boundary nav

- Add "Clear cache on exit" checkbox in Settings > Cache
- Fix ugoira zip conversion: don't crash if frames fail, verify gif
  exists before deleting zip
- Arrow key past last/first post loads next/prev page
This commit is contained in:
pax 2026-04-04 19:49:09 -05:00
parent ce51bfd98d
commit 148c1c3a26
3 changed files with 16 additions and 2 deletions

View File

@ -68,12 +68,14 @@ def _convert_ugoira_to_gif(zip_path: Path) -> Path:
except Exception:
continue
if not frames:
raise ValueError("Zip contains no image frames")
# Can't convert — just return the zip path as-is
return zip_path
frames[0].save(
gif_path, save_all=True, append_images=frames[1:],
duration=80, loop=0, disposal=2,
)
zip_path.unlink()
if gif_path.exists():
zip_path.unlink()
return gif_path

View File

@ -787,6 +787,10 @@ class BooruApp(QMainWindow):
if 0 <= idx < len(self._posts):
self._grid._select(idx)
self._on_post_activated(idx)
elif idx >= len(self._posts) and direction == 1 and len(self._posts) > 0:
self._next_page()
elif idx < 0 and direction == -1 and self._current_page > 1:
self._prev_page()
def _favorite_from_preview(self) -> None:
idx = self._grid.selected_index
@ -1335,6 +1339,9 @@ class BooruApp(QMainWindow):
thumbs[index].set_saved_locally(True)
def closeEvent(self, event) -> None:
if self._db.get_setting_bool("clear_cache_on_exit"):
from ..core.cache import clear_cache
clear_cache(clear_images=True, clear_thumbnails=True)
self._db.close()
super().closeEvent(event)

View File

@ -166,6 +166,10 @@ class SettingsDialog(QDialog):
self._auto_evict.setChecked(self._db.get_setting_bool("auto_evict"))
limits_layout.addRow("", self._auto_evict)
self._clear_on_exit = QCheckBox("Clear cache on exit (session-only cache)")
self._clear_on_exit.setChecked(self._db.get_setting_bool("clear_cache_on_exit"))
limits_layout.addRow("", self._clear_on_exit)
layout.addWidget(limits_group)
# Cache actions
@ -614,6 +618,7 @@ class SettingsDialog(QDialog):
self._db.set_setting("preload_thumbnails", "1" if self._preload.isChecked() else "0")
self._db.set_setting("max_cache_mb", str(self._max_cache.value()))
self._db.set_setting("auto_evict", "1" if self._auto_evict.isChecked() else "0")
self._db.set_setting("clear_cache_on_exit", "1" if self._clear_on_exit.isChecked() else "0")
if self._file_dialog_combo is not None:
self._db.set_setting("file_dialog_platform", self._file_dialog_combo.currentText())
self.settings_changed.emit()