Skip to content

fix: Failure to create playlist from importing an M3U file with duplicate tracks - #486

Merged
cyanChill merged 1 commit into
devfrom
fix/m3u-duplicate-tracks
May 16, 2026
Merged

fix: Failure to create playlist from importing an M3U file with duplicate tracks#486
cyanChill merged 1 commit into
devfrom
fix/m3u-duplicate-tracks

Conversation

@cyanChill

@cyanChill cyanChill commented May 16, 2026

Copy link
Copy Markdown
Member

Why

This PR fixes an edge case which prevents the creation of a playlist when importing from an M3U file. The problem is that it's possible for the M3U file to reference the same track multiple time (ie: if it was created from a different app which supports having a track appear multiple times). In our case, we didn't account for this, so when we went to create the tracksToPlaylists relations, Drizzle will throw an error since we were trying to insert a new entry with a track id that's already used.

Checklist

  • Documentation is up to date to reflect these changes.
  • Ensure dependency licenses are up-to-date by running pnpm sync:licenses.
  • This diff will work correctly for pnpm android:prod.

Summary by CodeRabbit

  • Bug Fixes
    • Improved M3U playlist import efficiency by eliminating redundant track lookups for duplicate playlist entries, enhancing performance during backup restoration.

Review Change Stack

- This ensures no duplicate entries when importing an M3U playlist. Order should also be preserved.
- This assumes the issue is caused by duplicate tracks in the M3U file, which I guess could happen if the playlist it was generated from supports duplicate tracks.
@cyanChill cyanChill added the Bug Issue was opened via the bug report template. label May 16, 2026
@cyanChill
cyanChill merged commit 90a0791 into dev May 16, 2026
1 check passed
@cyanChill
cyanChill deleted the fix/m3u-duplicate-tracks branch May 16, 2026 01:14
@cyanChill

Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented May 16, 2026

Copy link
Copy Markdown
✅ Actions performed

Full review triggered.

@coderabbitai

coderabbitai Bot commented May 16, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b110a878-2741-42c5-a7cf-f00cab1f03fa

📥 Commits

Reviewing files that changed from the base of the PR and between 8adde73 and 77698ae.

📒 Files selected for processing (1)
  • mobile/src/modules/backup/M3U.ts

📝 Walkthrough

Walkthrough

This PR deduplicates track URIs computed during M3U playlist reading by wrapping the strategy-based URI mapping in a Set before converting it back to an array, preventing repeated playlist entries from generating redundant database lookups.

Changes

M3U Playlist URI Deduplication

Layer / File(s) Summary
Deduplicate trackUris in playlist reading
mobile/src/modules/backup/M3U.ts
readM3UPlaylist wraps the computed trackUris (absolute/relative/unmodified strategy mapping) in a Set to remove duplicates, then converts back to an array, ensuring repeated playlist entries do not create duplicate database lookup URIs.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

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

Labels

Bug Issue was opened via the bug report template.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: M3U Import fails due to Unique Constraint on duplicate tracks in tracks_to_playlists

1 participant