fix: downloaded episodes no longer appear as missing
Use the database as the authoritative source for missing-episode lists so that episodes marked is_downloaded=True are never shown as missing, even when the in-memory state is stale. Key changes: - EpisodeService.get_by_series() gains only_missing flag - AnimeService uses DB-backed episodeDict and preserves downloaded episodes during sync, skipping them when adding/removing missing episodes - DownloadService broadcasts series_updated after marking an episode downloaded so the frontend reflects the change immediately - Frontend filters out series with zero missing episodes client-side and fixes renderSeries to respect the active filter - Unit tests updated to assert the broadcast is sent
This commit is contained in:
@@ -275,7 +275,7 @@ class DownloadService:
|
||||
"""
|
||||
try:
|
||||
from src.server.database.connection import get_db_session
|
||||
from src.server.database.service import EpisodeService, AnimeSeriesService
|
||||
from src.server.database.service import AnimeSeriesService, EpisodeService
|
||||
|
||||
logger.info(
|
||||
"Attempting to mark episode as downloaded in DB: "
|
||||
@@ -362,6 +362,31 @@ class DownloadService:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Broadcast real-time update to frontend so the series card
|
||||
# immediately reflects the new downloaded state (no longer
|
||||
# shows the episode as missing) without waiting for a full
|
||||
# reload on DOWNLOAD_COMPLETED.
|
||||
try:
|
||||
await self._anime_service._broadcast_series_updated(
|
||||
series_key
|
||||
)
|
||||
logger.debug(
|
||||
"Broadcast series_updated after marking "
|
||||
"%s S%02dE%02d as downloaded",
|
||||
series_key,
|
||||
season,
|
||||
episode,
|
||||
)
|
||||
except Exception as broadcast_exc:
|
||||
logger.warning(
|
||||
"Failed to broadcast series update after marking "
|
||||
"%s S%02dE%02d as downloaded: %s",
|
||||
series_key,
|
||||
season,
|
||||
episode,
|
||||
broadcast_exc,
|
||||
)
|
||||
|
||||
return True
|
||||
except Exception as e:
|
||||
logger.error(
|
||||
|
||||
Reference in New Issue
Block a user