Skip to content

Keep a playlist's downloads in sync with the server - #1105

Open
herrerad85 wants to merge 1 commit into
eddyizm:developmentfrom
herrerad85:feat/keep-playlist-synced-273
Open

herrerad85 wants to merge 1 commit into
eddyizm:developmentfrom
herrerad85:feat/keep-playlist-synced-273

Conversation

@herrerad85

@herrerad85 herrerad85 commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Part of #273.

What this does

A playlist's overflow menu gets a checkable "Keep synced" item. Turning it on downloads every track not already downloaded or queued, and the check runs again on every page open and once at app start. With a download folder set, the check runs against the folder instead. A kept playlist's page asks the server on every open instead of its cached list.

Download all uses the same check, so already downloaded tracks no longer go back through the queue. A download start the system refuses from the background now logs and skips instead of crashing, for every download.

Keep synced is per playlist and per server, since two servers can hand out the same playlist id, and cleared when the playlist is deleted or the server no longer has it. This moves the database to version 23.

Tracks that leave the playlist stay downloaded, since a track remembers only one playlist and removing it could take one another playlist or album still needs. Nothing runs while the app is closed. Editing a server's address turns Keep synced off.

Tested

On an emulator and an android 16 device. Toggle on, a track added on the server then the page reopened, another added then the app reopened, wifi only holding a track back, no extra fetch on rotation, and the database moving from 22 to 23 over existing data. Keep synced was tested against three servers, and toggle on, reopen and app reopen ran with a download folder set.

Part of eddyizm#273, the half that works while the app is open. A playlist
marked Keep synced in its overflow menu downloads any track not yet
downloaded or queued when the flag is turned on, every time its page
opens, and once on every app open for every kept playlist. The page asks
the server for the songs again on every open of a kept playlist, because
the view model keeps the last list across reopens of the same playlist
and a stale list would miss exactly the tracks the flag exists to catch.
Tracks that leave the playlist stay downloaded, and a download row that
already names a playlist keeps it, because the download table has one
playlist column per track and removing on that basis would delete a
track another playlist or an album still owns.

Download all on the playlist page now goes through the same check.
Before this it handed every track to the download service, and media3
puts a completed download back in the queued state when it is added
again, so a playlist of already downloaded tracks ran through the
service a second time and its rows were rewritten.

The flag lives in a new synced_playlist table, database version 23,
keyed by playlist and server URL because playlist ids repeat across
servers, and cleaned up where pinned_playlist is, on a server error 70
and when a refresh finds the playlist gone. A track asked for in this
process counts as present, the download tracker only learned about one
once it completed, so without that every open during a long download
queued the whole playlist again. A service start the system refuses from
the background is logged and skipped instead of crashing. The app open
sync does not accept the cached copy of a playlist, a stale cache would
miss exactly the tracks it exists to catch, so offline it does nothing.

Not covered here and left for a follow up, checking while the app is
closed, which needs a scheduled worker.
@coderabbitai

coderabbitai Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 6d167fdb-2844-4f4d-8c00-4fa80722d035

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant