Sync quality: files downloaded in the old format are not re-fetched when the setting is the default #1
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The documented contract for
setSyncQuality(lib/data/repositories/playlist/song_downloader.dart:651) states: "files already stored in the old format are re-fetched in the new one, so the offline library ends up in the format the user asked for." On Android this does not hold for the default value (compressed). Setting Compressed when it is already selected does nothing; only toggling Original → Compressed re-fetches.Reproduction (Android, observed)
best, or before the setting existed).defaultSyncQuality,song_downloader.dart:112).Root cause
The format comparison (
_formatMatches,song_downloader.dart:1496) runs only inside_update(), which is reached only throughupdate(). Two paths block it:init()(song_downloader.dart:289-370) marks every existing library file asdownloaded(lines 324-346) with no format check, and does not run a sync pass. On startup, files in the old format are accepted as-is.setSyncQuality(song_downloader.dart:655) returns early when the value is unchanged:if (_syncQuality == quality) return ok. Since the default iscompressed, tapping Compressed when it is already selected is a no-op —update(true)is never called, so_update()never compares the stored task URLs against the wanted format.The stored format key is read from the task record's URL (
downloadFormatKeyOfUri,download_format.dart:75), so the comparison itself is the real, safe gate: it leaves files already in the wanted format untouched and refetches only the ones that do not match. The early-return is what defeats it.Fix
setSyncQuality: drop the same-value early-return. Store the value, set_syncQuality, and runupdate(true)unconditionally. The format comparison is idempotent, so setting the same value is safe (matching files are left alone) and it refetches the old-format files.init(): after the library is marked and the in-flight tasks are tracked (the end ofinit, beforenotifyListeners), runupdate(true)so a default-compressedclient refetches files downloaded in the old format on startup. This closes the upgrade case.Tests to add
In
test/data/repositories/playlist/song_downloader_test.dart, mirroring the existing harness (makeSong,keyValue,repo, thedownloadUriForassertions at lines 741-775):setSyncQuality(compressed)when the in-memory value is alreadycompressedrunsupdate(true)and re-fetches a task whose stored URL is/rest/downloadas/rest/stream?format=mp3&maxBitRate=320.init()on a tree whose task records areoriginaland whose stored quality is absent (defaultcompressed) re-fetches them as the transcode.Device proof (Android emulator)
Build a fork-signed APK from the worktree (copy
android/key.propertiesfrom the shared clone;apksigner verify --print-certsmust showCN=Crossonic Fork), install over the existing install on the emulator, and prove:log_messageincrossonic_database.sqlite, read viaadb exec-out tar) shows the delete + re-enqueue lines for the old-format files.Acceptance criteria
flutter analyze0 errors,flutter testall pass, the two new tests present.devand the next beta publishes.