From 28922ad2c1768910920e4a6ddf290bb08db775a9 Mon Sep 17 00:00:00 2001 From: Broque Thomas <26755000+Nezreka@users.noreply.github.com> Date: Sun, 24 May 2026 14:56:34 -0700 Subject: [PATCH] Cap persistent download history response Stop appending persistent download history once the unified downloads payload reaches the requested limit. This keeps the Downloads tab history tail bounded even if the history provider returns more rows than requested, while preserving existing live-task total behavior. --- core/downloads/status.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/downloads/status.py b/core/downloads/status.py index 37ae441d..7f2230bd 100644 --- a/core/downloads/status.py +++ b/core/downloads/status.py @@ -703,13 +703,17 @@ def build_unified_downloads_response(limit: int, deps: StatusDeps) -> dict: logger.debug("[Downloads] persistent history lookup failed: %s", exc) history_entries = [] + appended_history = 0 for entry in history_entries: + if len(items) >= limit or appended_history >= history_limit: + break item = _build_history_download_item(entry) identity = _download_identity(item.get('title'), item.get('artist'), item.get('album')) if identity in live_identities: continue items.append(item) live_identities.add(identity) + appended_history += 1 # Sort: active first (by priority), then by timestamp desc within each group items.sort(key=lambda x: (x['priority'], -x['timestamp']))