Files
navidrome/tests
Deluan Quintão d4b2499e1e fix(server): return correct scanType in startScan response (#5159)
* fix(api): return correct scanType in startScan response

The startScan endpoint launches the scan in a goroutine and immediately
calls GetScanStatus to build the response. Because the scanner hasn't
had time to initialize and write its state to the database, the response
contained stale data from the previous scan (e.g., scanType "quick"
when fullScan=true was requested).

Add a polling loop that waits briefly (up to 3s, polling every 50ms) for
the scanner to report Scanning=true before returning the status. If the
timeout expires, it falls back to the current behavior (no regression).

Fixes #5158

* fix(api): use ticker/timer with context cancellation for scan polling

Replace time.Sleep loop with proper ticker, timer, and ctx.Done()
handling so the poll exits cleanly on timeout or client disconnect.

* fix(api): handle fast scan completion in poll loop

Add a channel to detect when the scan goroutine finishes before the
poll loop observes Scanning=true, avoiding a 3s timeout on very fast
scans. Use defer close to handle both success and error paths.
2026-03-09 14:19:53 -04:00
..