spotube/lib/provider/server
Tomasz Jabłonowski 19adaf5e54 fix(server): race condition and cache corruption in playback routes
Two related bugs in ServerPlaybackRoutes:

1. _getSourcedTrack looked up the requested media in
   audioPlayer.playlist.medias by URI, but MPV issues its HTTP request
   before media_kit's Dart-side state has synced with the native
   player, so the lookup threw "Bad state: No element" and the proxy
   returned 500 ("Failed to open" in MPV). Now resolves the track
   directly from playlist.tracks by trackId via firstWhereOrNull,
   independent of the player's media list.

2. MPV opens multiple concurrent range requests for the same track
   (buffering/seek/reconnect), each opening its own writeOnlyAppend
   sink to the same .part cache file; the final rename would then fail
   with a file-in-use error (or corrupt the cache from concurrent
   appends). Added a _cachingInProgress guard so only one request
   caches a given track at a time, cache only full requests
   (contentRange.start == 0), write with truncate instead of append,
   and clean up the in-progress marker/partial file in finally.

Fixes #3089
2026-07-26 10:39:07 +02:00
..
routes fix(server): race condition and cache corruption in playback routes 2026-07-26 10:39:07 +02:00
active_track_sources.dart feat: move away from track source query and preferences audio quality and codec 2025-11-03 19:33:47 +06:00
bonsoir.dart refactor: merge connect and playback server into one server 2024-06-12 20:46:49 +06:00
pipeline.dart refactor: merge connect and playback server into one server 2024-06-12 20:46:49 +06:00
router.dart chore: streaming issue for mp3 2025-09-19 21:40:26 +06:00
server.dart fix: remote path traversal through websocket when devices are on same network 2025-04-27 20:30:32 +06:00
sourced_track_provider.dart feat: move away from track source query and preferences audio quality and codec 2025-11-03 19:33:47 +06:00