Repository navigation
pdb: keep USB file names apart when the caps make them collide - #156
Merged
Merged
Conversation
PrepareUSBLayout caps a file name at 48 characters, or less to keep the whole path within 126, but never checked whether the capped path was already taken in the export. Two tracks whose names share their first 44 characters landed on one path, as did names that differ only in case, which FAT32 folds together. The second copy overwrote the first, and both PDB rows played it. Exporting an S3RL pack, "S3RL & Synthwulf - Everybody Wants to be a DJ [Wav File].wav" and its "(S3RL hard mix) [Wav File].wav" both became ".../S3RL & Synthwulf - Everybody Wants to be a D.wav", and picking the plain version on the deck played the hard mix. The export now remembers the paths it has handed out, compared in lower case as FAT does, and gives a later colliding name " (2)", " (3)" and so on before its extension, shortening the base to stay within the same cap: the hard mix becomes ".../S3RL & Synthwulf - Everybody Wants to be (2).wav". Names that don't collide are unchanged. TestPrepareUSBLayoutKeepsCollidingNamesApart lays out both cases and checks that every row gets its own path and plays its own file. On main both pairs share a path, and the plain mix's row plays the hard mix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
WOLFI3654
marked this pull request as ready for review
November 2, 2026 16:17
vynulldev
requested changes
Nov 3, 2026
vynulldev
left a comment
Owner
There was a problem hiding this comment.
Thanks for finding this bug and pushing the PR! Just had a couple quick requests before merging:
5 tasks done
vynulldev
added a commit
that referenced
this pull request
Nov 4, 2026
A merge export laid out every track again, computing its stick path from its tags, and matched it to the stick's rows by that path. A track whose artist or album had changed since it was exported got a new folder: it was copied a second time and added as a second row, while the stick's playlists kept the old copy. And with colliding file names kept apart (#156), a re-export in another order would swap the two tracks' files and IDs, changing the stick's playlists. rekordbox keeps a track already on the stick at its file and ID when it is exported again. keepOnStick now does the same before the layout: a track whose source has the same bytes as a file the stick holds (the same size, then the same first and last 64 KiB) keeps that file's path, so the merge reuses its row and ID and doesn't copy it again. Only the other tracks are laid out. A track the export re-encodes never matches, as the stick holds the re-encode.
Owner
|
Hey @WOLFI3654 I'd like to do a release this week and I'd love to get this fix into it! I can go ahead and push a new PR with your patch + the requested changes and credit you with co-author if that's easier. Let me know otherwise, thanks! |
Contributor
Author
oh thought i did. will do shortly :) |
Follow-up to the review. rekordbox 7 names a colliding file "-1", "-2"
and so on before its extension ("Same Name.mp3", "Same Name-1.mp3"),
the base shortened so the whole name stays within the cap, so the
export now does the same instead of " (2)". The track exported first
keeps the plain name, as in rekordbox.
Cutting a name to its cap now stops at the start of a character, so a
cut never splits a multi-byte one into invalid UTF-8. TruncateFilename
cut by bytes too and shares the fix.
The test uses made-up names, and adds the same name from two folders,
a third long name ("-2") and cuts through an "é".
vynulldev
approved these changes
Nov 21, 2026
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.
What & why
PrepareUSBLayout caps a file name at 48 characters, or less to keep
the whole path within 126, but never checked whether the capped path
was already taken in the export. Two tracks whose names share their
first 44 characters landed on one path, as did names that differ only
in case, which FAT32 folds together. The second copy overwrote the
first, and both PDB rows played it.
Exporting an S3RL pack, "S3RL & Synthwulf - Everybody Wants to be a
DJ [Wav File].wav" and its "(S3RL hard mix) [Wav File].wav" both
became ".../S3RL & Synthwulf - Everybody Wants to be a D.wav", and
picking the plain version on the deck played the hard mix.
The export now remembers the paths it has handed out, compared in
lower case as FAT does, and gives a later colliding name " (2)",
" (3)" and so on before its extension, shortening the base to stay
within the same cap: the hard mix becomes ".../S3RL & Synthwulf -
Everybody Wants to be (2).wav". Names that don't collide are
unchanged.
TestPrepareUSBLayoutKeepsCollidingNamesApart lays out both cases and
checks that every row gets its own path and plays its own file. On
main both pairs share a path, and the plain mix's row plays the hard
mix.
Hardware testing
Checklist
go build ./...,go vet ./..., andgo test ./...pass (exceptnfs/TestMP3SizePredicted, which fails onmaintoo with ffmpeg 9.0.2, whose FLAC encoder rejects the test fixture: "invalid block size: 1")gofmt -l .is cleanGPL-3.0-or-later)🤖 Generated with Claude Code