From f7670963df2b298548aaf109f28d6363690bae19 Mon Sep 17 00:00:00 2001 From: jtrzupek Date: Wed, 10 Jun 2026 14:29:24 +0200 Subject: [PATCH] =?UTF-8?q?fix(sxyprn):=20disable=20thumbnail=20refresh=20?= =?UTF-8?q?job=20=E2=80=94=20trafficdeposit=20token=20has=20~1h=20TTL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CORRECTION: trafficdeposit thumbnail tokens are hour-bucketed and valid only ~1h (verified 2026-06-10: stored ts=11:00 dead at 12:27, current ts=13:00 loads). Earlier "~weekly rot" read was wrong. Storing/periodically-refreshing sxyprn thumbnail URLs is futile — they expire within the hour. Default the refresh job OFF (kept in code). The dead-marking sweep (Post Not Found → dead_at) it performed was still valid. Live sxyprn thumbnails need on-demand resolution at serve time (future work). Co-Authored-By: Claude Opus 4.8 --- app/scheduler/jobs.py | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/app/scheduler/jobs.py b/app/scheduler/jobs.py index eb419d7..7db0d28 100644 --- a/app/scheduler/jobs.py +++ b/app/scheduler/jobs.py @@ -208,7 +208,7 @@ def _job_refresh_sxyprn_thumbs(batch: int = 1200) -> None: from sqlalchemy import text from app.db import session_scope - from scripts.refresh_sxyprn_thumbs import _fresh_thumb + from scripts.refresh_sxyprn_thumbs import refresh_batch with session_scope() as session: rows = session.execute( @@ -218,19 +218,11 @@ def _job_refresh_sxyprn_thumbs(batch: int = 1200) -> None: "ORDER BY updated_at ASC LIMIT :n" ).bindparams(n=batch) ).all() - updated = 0 - for pbid, page_url in rows: - thumb = _fresh_thumb(page_url) - if thumb: - with session_scope() as session: - session.execute( - text("UPDATE playback_sources SET thumbnail_url=:t WHERE id=:i").bindparams( - t=thumb, i=pbid - ) - ) - session.commit() - updated += 1 - log.info("[scheduler] sxyprn thumb refresh done: %d/%d", updated, len(rows)) + refreshed, dead, untouched = refresh_batch(list(rows)) + log.info( + "[scheduler] sxyprn thumb refresh done: refreshed=%d dead=%d untouched=%d (of %d)", + refreshed, dead, untouched, len(rows), + ) _run_with_timeout(_run, label="sxyprn-thumb-refresh") @@ -423,10 +415,13 @@ def build_scheduler(cfg: dict[str, Any]) -> BlockingScheduler: ) log.info("scheduler: reap-stuck every %dh", reap_hours) - # sxyprn thumbnail refresh — sxyprn miniaturki rotują (signed CDN, 404 po ~tygodniach). - # Domyślnie ZAWSZE on co 12h, batch najdawniej-aktualizowanych → cykl po katalogu w - # ~tydzień (mieści się w oknie wygaśnięcia). Bug 2026-06-10. - sxyprn_hours = cfg.get("sxyprn_thumb_refresh_hours", 12) + # sxyprn thumbnail refresh — WYŁĄCZONE (default 0). Token trafficdeposit jest + # bucketowany godzinowo i ważny ~1h (weryfikacja 2026-06-10: stored ts=11:00 martwy + # o 12:27, aktualny ts=13:00 żyje). Przechowywanie URL-i jest bezcelowe — wygasają + # w godzinę, więc periodyczny refresh tylko wali w sxyprn na darmo. Działające + # thumbnaile sxyprn wymagają ON-DEMAND resolve przy serwowaniu (proxy fetch post + # page → bieżący og:image, cache ~45min). Job zostaje w kodzie ale domyślnie off. + sxyprn_hours = cfg.get("sxyprn_thumb_refresh_hours", 0) if sxyprn_hours: batch = cfg.get("sxyprn_thumb_refresh_batch", 1200) sched.add_job( @@ -445,7 +440,7 @@ def build_scheduler(cfg: dict[str, Any]) -> BlockingScheduler: DEFAULT_CONFIG: dict[str, Any] = { "tpdb_hours": 6, "stashdb_hours": 6, - "sxyprn_thumb_refresh_hours": 12, + "sxyprn_thumb_refresh_hours": 0, # off — token ~1h TTL, refresh bezcelowy (patrz register_jobs) "sxyprn_thumb_refresh_batch": 1200, "performer_driven_hours": 12, "performer_driven_top_n": 20,