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.
This commit is contained in:
parent
28641403d9
commit
28922ad2c1
1 changed files with 4 additions and 0 deletions
|
|
@ -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']))
|
||||
|
|
|
|||
Loading…
Reference in a new issue