From 5d48581f52ee30d05ff509bea8db77b499801b70 Mon Sep 17 00:00:00 2001 From: pax Date: Sun, 5 Apr 2026 00:32:04 -0500 Subject: [PATCH] Prefetch in all 4 directions (left, right, up, down) CDN downloads don't count against API rate limits so we can safely prefetch all adjacent posts for instant navigation. --- booru_viewer/gui/app.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/booru_viewer/gui/app.py b/booru_viewer/gui/app.py index 81b4930..25e31cb 100644 --- a/booru_viewer/gui/app.py +++ b/booru_viewer/gui/app.py @@ -765,13 +765,13 @@ class BooruApp(QMainWindow): self._prefetch_adjacent(index) def _prefetch_adjacent(self, index: int) -> None: - """Silently download adjacent posts with staggered delays.""" + """Prefetch posts in all 4 directions (left, right, up, down).""" + cols = self._grid._flow.columns + offsets = [1, -1, cols, -cols] async def _prefetch_batch(): - for i, offset in enumerate((1, -1)): + for offset in offsets: adj = index + offset if 0 <= adj < len(self._posts) and self._posts[adj].file_url: - if i > 0: - await asyncio.sleep(1) try: await download_image(self._posts[adj].file_url) except Exception: