fix(worker): mark the chosen candidate at download-start, not after success
_mark_chosen ran only after a download succeeded, so throughout the 'downloading' state no candidate was chosen — the Floor row's "source · format · tracks" line was blank (only elapsed showed). Now mark the candidate exclusively at each download attempt so `chosen` reflects the source in flight (and updates on fall-through). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -46,6 +46,20 @@ def test_falls_through_when_best_download_fails(conn):
|
||||
assert cur.fetchone()[0] == "soulseek"
|
||||
|
||||
|
||||
def test_fallthrough_marks_exactly_one_chosen(conn):
|
||||
# `chosen` now marks the source in flight at each attempt; after falling through from a
|
||||
# failed source to a working one, exactly ONE candidate stays chosen (the winner) — the
|
||||
# attempted-then-failed source must be un-marked (exclusive _mark_chosen).
|
||||
job_id = insert_request(conn, artist="Radiohead", album="In Rainbows")
|
||||
claim_next(conn)
|
||||
run_pipeline(conn, job_id, [FailingAdapter(), FakeSoulseek()], dest_root="/tmp/lib")
|
||||
with conn.cursor() as cur:
|
||||
cur.execute('SELECT count(*) FROM "Candidate" WHERE "jobId" = %s AND chosen = true', (job_id,))
|
||||
assert cur.fetchone()[0] == 1
|
||||
cur.execute('SELECT source FROM "Candidate" WHERE "jobId" = %s AND chosen = true', (job_id,))
|
||||
assert cur.fetchone()[0] == "soulseek"
|
||||
|
||||
|
||||
def test_no_match_goes_to_needs_attention(conn):
|
||||
job_id = insert_request(conn, artist="Radiohead", album="In Rainbows")
|
||||
claim_next(conn)
|
||||
|
||||
Reference in New Issue
Block a user