From ebda0b8613e2f1b5b55cea66d2e4c19426963d96 Mon Sep 17 00:00:00 2001 From: Broque Thomas <26755000+Nezreka@users.noreply.github.com> Date: Sat, 16 May 2026 10:37:29 -0700 Subject: [PATCH] fix(amazon): _record_to_status read 'filename' not 'original_filename' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The engine worker stores the encoded filename under the key 'filename' (see worker.py dispatch). _record_to_status was reading 'original_filename', which always returns "" — so every DownloadStatus emitted by get_all_downloads/get_download_status had an empty filename string. The download monitor builds lookup keys as _make_context_key(download.username, download.filename). With filename="" the key was always "amazon::" which never matched the task's "amazon::B0B1234||Artist - Title" key. Monitor never detected Amazon download completions, so tasks sat stuck at Downloading 0% forever even though the files had actually downloaded. Also fixes tests that had the same wrong key. --- core/amazon_download_client.py | 2 +- tests/tools/test_amazon_download_client.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/amazon_download_client.py b/core/amazon_download_client.py index fb5dcdb6..44c92474 100644 --- a/core/amazon_download_client.py +++ b/core/amazon_download_client.py @@ -431,7 +431,7 @@ class AmazonDownloadClient(DownloadSourcePlugin): def _record_to_status(download_id: str, rec: Dict[str, Any]) -> DownloadStatus: return DownloadStatus( id=download_id, - filename=str(rec.get("original_filename", "")), + filename=str(rec.get("filename", "")), username="amazon", state=str(rec.get("state", "queued")), progress=float(rec.get("progress", 0.0)), diff --git a/tests/tools/test_amazon_download_client.py b/tests/tools/test_amazon_download_client.py index 0ab0f85b..47ea0715 100644 --- a/tests/tools/test_amazon_download_client.py +++ b/tests/tools/test_amazon_download_client.py @@ -325,7 +325,7 @@ class TestUniquePath: class TestRecordToStatus: def test_fields_mapped(self): rec = { - "original_filename": "B1||Artist - Title", + "filename": "B1||Artist - Title", "state": "downloading", "progress": 0.5, "size": 10_000_000, @@ -718,7 +718,7 @@ class TestStatusInterface: engine = MagicMock() engine.get_all_records.return_value = { "dl-001": { - "original_filename": "B1||A - T", + "filename": "B1||A - T", "state": "complete", "progress": 1.0, "size": 5_000_000,