From b16610ac63e72bbb7db773ca5fd35688f8ff3fb5 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 4 Feb 2026 12:53:42 -0700 Subject: [PATCH] fix(progress): bind per-track bars and force terminal completion --- unshackle/core/tracks/tracks.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/unshackle/core/tracks/tracks.py b/unshackle/core/tracks/tracks.py index ff0e646..7d22291 100644 --- a/unshackle/core/tracks/tracks.py +++ b/unshackle/core/tracks/tracks.py @@ -121,24 +121,27 @@ class Tracks: speed_estimate_period=10, ) task = progress.add_task("", downloaded="-") + state = {"total": 100.0} - current_total = 100.0 - - def update_track_progress(task_id: int = task, **kwargs) -> None: + def update_track_progress( + task_id: int = task, + _state: dict[str, float] = state, + _progress: Progress = progress, + **kwargs, + ) -> None: """ Ensure terminal status states render as a fully completed bar. Some downloaders can report completed slightly below total before emitting the final "Downloaded" state. """ - nonlocal current_total if "total" in kwargs and kwargs["total"] is not None: - current_total = kwargs["total"] + _state["total"] = kwargs["total"] downloaded_state = kwargs.get("downloaded") if downloaded_state in {"Downloaded", "Decrypted", "[yellow]SKIPPED"}: - kwargs["completed"] = current_total - progress.update(task_id=task_id, **kwargs) + kwargs["completed"] = _state["total"] + _progress.update(task_id=task_id, **kwargs) progress_callables.append(update_track_progress) track_table = Table.grid()