fix(r5): address the second /code-review high round — 7 findings

- the volume keys no longer defer to a scrollable card while in fullscreen
  (mirrored into a ref: the keydown handler is bound once and state would be stale)
- the debounced volume flush writes straight to storage; persisting inside a
  setState updater is not guaranteed to run for an unmounting component
- the HLS sweep also matches the original {key}_{start} directory naming, which
  is what the oldest leftovers on disk actually use
- run_rss_poll returns {new, failed} so an egress outage stops rendering as
  "ok — 0" in the scheduler card and the audit log; /api/sync/rss reports it too
- drop the unused poll_rss_channel (it silently gained a new exception)
- _Breaker.run is generic, so a call site keeps its item-id type
- test helper instead of the generator-throw idiom
This commit is contained in:
2026-07-23 23:59:58 +02:00
parent 2a7f49c981
commit 53ff61653d
7 changed files with 55 additions and 26 deletions
+11 -3
View File
@@ -9,6 +9,7 @@ import hashlib
import logging
from collections.abc import Callable
from datetime import datetime, timezone
from typing import TypeVar
from sqlalchemy import delete, select
from sqlalchemy.orm import Session
@@ -272,8 +273,15 @@ def plan_push(db: Session, user: User, pl: Playlist, *, live=None) -> dict:
_MAX_CONSECUTIVE_FAILURES = 5
class _Failed:
"""Type of the `FAILED` sentinel, so `run()` can stay generic in the op's return type: a call
site gets back `str | _Failed` (not a bare `object`) and keeps its item id typed."""
#: Returned by `_Breaker.run` when the write did not happen (refused or failed).
FAILED = object()
FAILED = _Failed()
T = TypeVar("T")
class _Breaker:
@@ -305,7 +313,7 @@ class _Breaker:
self.limit,
)
def run(self, op: Callable[[], object], on_fail: Callable[[], None]) -> object:
def run(self, op: Callable[[], T], on_fail: Callable[[], None]) -> T | _Failed:
"""Attempt one YouTube write. Returns the op's result, or `FAILED` when the breaker is
already tripped (op not called) or the op raised YouTubeError. `on_fail` records the item
in the caller's failure list either way."""
@@ -387,7 +395,7 @@ def push_playlist(db: Session, user: User, pl: Playlist, *, live=None) -> dict:
lambda v=vid: yt.add_playlist_item(pl.yt_playlist_id, v),
lambda v=vid: failures.append(v),
)
if item_id is not FAILED:
if not isinstance(item_id, _Failed):
item_id_by_vid[vid] = item_id
inserted += 1
# Reorder to match `desired` via insertion-sort moves over a local model.