fix(sync): write playlist .m3u manifests to the device - #267
Merged
Conversation
Playlists copied to a device contained the audio files but no .m3u manifest, so media players could not open a synced playlist as a unit. The local manifests were generated correctly (#255), but the device-sync path never copied them: scan_playlists_for_sync only scanned each playlist's audio/ subfolder, so the sibling manifest was never added to the sync set. A verbatim copy would also have been broken, because device sync flattens playlists (Playlists/<name>/audio/<file> -> Playlists/<name>/<file>) while the local manifest references audio/<file>. sync_to_device now writes a device-layout manifest at Playlists/<name>/<name>.m3u for every playlist with synced audio, rewriting each path line to drop the audio/ prefix while preserving #EXTM3U/#EXTINF titles and order. Writes are idempotent (unchanged manifests skipped), honored in dry-run, regenerated by hard sync, and - since .m3u files are excluded from the audio-only device scan - a dedicated pass removes a stale device manifest once its playlist no longer has synced audio. Adds a pure PlaylistFileManager::transform_m3u_for_device helper (5 unit tests) and 5 integration tests covering write/strip, idempotent skip, orphan removal, dry-run, and hard-sync regeneration. Closes #266 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #266 — Playlists copied to a device contained the audio files but no
.m3umanifest, so media players couldn't open a synced playlist as a unit.The local manifests were generated correctly (#255), but the device-sync path never copied them:
scan_playlists_for_sync(src/download/manager.rs) only scanned each playlist'saudio/subfolder, so the sibling<name>.m3uwas never added to the sync set. A verbatim copy would also have been broken — device sync flattens playlists (Playlists/<name>/audio/<file>→Playlists/<name>/<file>, noaudio/subfolder) while the local manifest referencesaudio/<file>.sync_to_devicenow writes a device-layout manifest atPlaylists/<name>/<name>.m3ufor every playlist with synced audio, rewriting each path line to drop theaudio/prefix while preserving#EXTM3U/#EXTINFtitles and episode order.Changes
src/playlist/file_manager.rs: add purePlaylistFileManager::transform_m3u_for_devicehelper (strips a leadingaudio/oraudio\from path lines; leaves#EXTM3U/#EXTINFand already-flat paths untouched).src/download/manager.rs: add async_playlist_manifestsstep tosync_to_device(after audio copy, before orphan deletion). It:pc_files,.m3uis excluded from the audio-onlydevice_filesscan),dry_run(reported, not written),hard_sync,.m3u).CHANGELOG.md:[Unreleased]→ Fixed entry.docs/DEVICE_PROFILES.md: correct the playlist-manifest paragraph to describe the flat device layout.Manual Testing
…/data/playlists/<name>/<name>.m3uexists locally).F8), pick the device directory, and run a sync.<device>/Playlists/<name>/held only001-….mp3files, no manifest.After:
<device>/Playlists/<name>/<name>.m3uexists; open it in a media player → loads the episodes in order.001-….mp3), notaudio/001-….mp3;#EXTINFtitles preserved..m3u(and audio) are removed.Tests
file_manager.rs): strip prefix, preserve directives/order, header-only, non-audio/passthrough, backslash prefix.manager.rs): device m3u written with stripped paths, idempotent skip + not orphan-deleted, removed when playlist removed, dry-run writes nothing but reports, hard-sync regenerates.Quality
cargo fmt --check✅cargo clippy --all-targets -- -D warnings✅cargo test✅