Repository navigation
export: keep tracks already on the stick where they are - #168
Merged
Merged
Conversation
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.
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
A merge export lays out every track again: it computes the track's stick path from its tags, copies the file there, and matches the track to the stick's existing rows by that path. Two things go wrong:
We tested rekordbox 7 on the same case. It also names colliding files first come, first served, but a re-export changes nothing: tracks already on the stick keep their files, names and IDs, and the new playlist points at them.
Changes:
keepOnStickruns before the layout in a merge export. A track whose source has the same bytes as a file the stick already holds keeps that file's path. The merge then reuses that row's ID, as it already does for a matching path, and the file isn't copied again. Only the remaining tracks are laid out and copied.Checked end to end through the export API (throwaway servers in a loopback-only network namespace, two real MP3s, reading each stick's PDB and the file each row points at):
Tests (
export/onstick_test.go):sameEndscompares both ends, and handles a file shorter than 64 KiB.Not in this PR: naming new tracks around the names already on the stick. That's collision handling, which #156 is reworking. Once #156 lands, its collision check can also count the stick's existing names.
Build, vet, all tests and the race detector on the export and pdb packages pass, and
deadcodereports what it does on main. The end-to-end suite passes. Conformance against main is unchanged: 3,091/4,250 exact on both, nothing gained or lost.Hardware testing
Checklist
go build ./...,go vet ./..., andgo test ./...passgofmt -l .is cleanGPL-3.0-or-later)