Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically update track metadata from file tags if outdated #4218

Merged
merged 15 commits into from Oct 17, 2021
Merged

Automatically update track metadata from file tags if outdated #4218

merged 15 commits into from Oct 17, 2021

Conversation

uklotzde
Copy link
Contributor

@uklotzde uklotzde commented Aug 17, 2021

TODO:

When loading a track from the database check if the underlying file has been modified. If the time stamp is newer than the timestamp of the last synchronization then update track metadata from file tags. Please note that this only works for files that have been (re-)imported with the new sourceSynchronizedAt property populated. Existing tracks in the library are not updated to prevent overwriting of modified data.

Restriction: Only iff export of track metadata into file tags has been enabled by the user to reduce surprising side-effects to a minimum. Introducing a new configuration option for this feature has deliberately been avoided to reduce the number of possible configurations. Either you want to keep your file tags synchronized or not, no exceptions! Consequently I have re-phrased the preference options.

Migration

Existing files without a synchronization time stamp are unaffected. The following query could be used to enforce that those files are re-imported eventually:

UPDATE library SET source_synchronized_ms = 0 WHERE source_synchronized_ms IS NULL;

Currently, there is no user operation in Mixxx to trigger this. If we want to offer this option to users we need to be clear about the consequences! The next time when such a file/track is loaded its properties in Mixxx will be replaced unconditionally with values from the file tags. Beat grid and cue points are preserved, as well as properties that are missing in file tags. Out of scope of this PR.

The query is also useful for testing, if you are sure that your file tags are up-to-date or considered more recent than the information stored in Mixxx.

@uklotzde uklotzde changed the title Automatically update track metadata from file tags if outdated [WiP] Automatically update track metadata from file tags if outdated Aug 17, 2021
@uklotzde uklotzde marked this pull request as draft August 17, 2021 15:45
@coveralls
Copy link

coveralls commented Aug 17, 2021

Pull Request Test Coverage Report for Build 1154288098

  • 51 of 82 (62.2%) changed or added relevant lines in 11 files are covered.
  • 4 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.01%) to 25.98%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/dialog/dlgkeywheel.cpp 0 1 0.0%
src/library/dao/trackdao.cpp 7 8 87.5%
src/sources/metadatasource.cpp 5 6 83.33%
src/widget/wtracktableview.cpp 4 5 80.0%
src/library/library.cpp 0 2 0.0%
src/track/track.cpp 6 9 66.67%
src/sources/soundsourceproxy.cpp 12 22 54.55%
src/track/trackrecord.cpp 8 20 40.0%
Files with Coverage Reduction New Missed Lines %
src/engine/cachingreader/cachingreaderworker.cpp 2 63.48%
src/sources/soundsourceproxy.cpp 2 63.16%
Totals Coverage Status
Change from base Build 1153454756: 0.01%
Covered Lines: 20029
Relevant Lines: 77093

💛 - Coveralls

@Holzhaus
Copy link
Member

Did you consider the special case where the user has metadata export enabled, but not Serato metadata export? Or should we exclude serato metadata completely because it's not completely lossless?

@uklotzde
Copy link
Contributor Author

Did you consider the special case where the user has metadata export enabled, but not Serato metadata export? Or should we exclude serato metadata completely because it's not completely lossless?

I have reverted the preference changes regarding Serato metadata.

There should not be any distinction between an automatic or manual import/export, both should behave exactly the same.

I don't want to split the option into Export only (one-way sync) and "Export/Re-import" (two-way sync). Every new option increases the maintenance burden. Either all-in (= full sync) or all-out (= no sync), but no middle ground.

Please give an example where this doesn't work as expect for a file with Serato tags. Then we can create a test and try to find a solution for resolving the issues.

@Holzhaus
Copy link
Member

I'm open to remove the separate preferences option for serato export, as there doesn't seem to be major issues with it (or nobody besides me tested it).

However, I'm worried about potential data loss. For example, saved loops can't have a color in serato, but they can in Mixxx.

What happens in the following case?

  1. Add loops with colors in Mixxx
  2. Export to tags (color is lost)
  3. Edit file tags outside mixxx (e. g. to correct typo in artist name or something)
  4. Mixxx detects file as modified and Reimport tags automatically => will loop colors be lost?

@uklotzde
Copy link
Contributor Author

uklotzde commented Aug 18, 2021

How to merge existing data with (re-)imported data from Serato tags must be solved in the Serato tag import code. This issue also occurs when re-importing metadata manually. We need to investigate that.

I have already experienced issues with the round-trip in the past and had to disable writing of Serato tags: https://bugs.launchpad.net/mixxx/+bug/1921646

When loading a track from the database check if the underlying file
has been modified. If the time stamp is newer than the timestamp of
the last synchronization then update track metadata from file tags.

But only if export of track metadata into file tags has been enabled
by the user to reduce surprising side-effects to a minimum. Introducing
a new configuration option for this feature has deliberately been avoided
to reduce the number of possible configurations. Either you want to
keep your file tags synchronized or not, no exceptions!

# Conflicts:
#	src/sources/metadatasourcetaglib.cpp
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkBox_SeratoMetadataExport">
<property name="text">
<string>Write Serato Metadata to files (experimental)</string>
<string>Write Serato metadata to files (experimental)</string>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this now also in both directions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Serato metadata is implicitly re-imported if available. Not sure what happens when new cue points/loops and color have been edited in Mixxx and the file is re-imported.

I have added a TODO.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Holzhaus Can you test/explain the situation, that we can adjust the text in one or the other direction?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done
serato-metadata

@uklotzde uklotzde changed the title [WiP] Automatically update track metadata from file tags if outdated Automatically update track metadata from file tags if outdated Sep 6, 2021
@uklotzde
Copy link
Contributor Author

I'm open to remove the separate preferences option for serato export, as there doesn't seem to be major issues with it (or nobody besides me tested it).

However, I'm worried about potential data loss. For example, saved loops can't have a color in serato, but they can in Mixxx.

What happens in the following case?

1. Add loops with colors in Mixxx

2. Export to tags (color is lost)

3. Edit file tags outside mixxx (e. g. to correct typo in artist name or something)

4. Mixxx detects file as modified and Reimport tags automatically => will loop colors be lost?

I don't have the time to deal with these incompatibilities or special cases that may only affect a few users. The only option then is to introduce a new preference setting that explicitly enables re-import of updated metadata with a disclaimer.

@uklotzde
Copy link
Contributor Author

Changing the current behavior of how Serato metadata is synchronized is out of scope. If merging of existing with imported metadata is desired then this has to be implemented separately, non-trivial. Currently metadata is simply replaced. The behavior is documented and the user is informed about it, see https://github.com/uklotzde/mixxx/commit/f315803dc36442306bb5b4bf1cf9c51a7a131f28.

@daschuer
Copy link
Member

This is becoming mature. Is it still a draft? I think it required some manual tests. Please remove the draft state of ready for that.

@uklotzde uklotzde marked this pull request as ready for review September 16, 2021 20:14
@Be-ing
Copy link
Member

Be-ing commented Oct 12, 2021

@Holzhaus will you have time to do a final review soon?

@Holzhaus
Copy link
Member

@Holzhaus will you have time to do a final review soon?

Yes, I can do that. Note that @daschuer requested changes and needs to give his approval, too.

@uklotzde
Copy link
Contributor Author

uklotzde commented Oct 12, 2021

@Holzhaus will you have time to do a final review soon?

Yes, I can do that. Note that @daschuer requested changes and needs to give his approval, too.

I didn't rebase on purpose and resolved the recent conflicts by merging. No substantial changes expected.

The TODOs are just sit there as a reminder what would be desirable. Edit: Marked as optional, because I am unsure how much more time I am willing to spend on this.

@uklotzde
Copy link
Contributor Author

Please note that I marked this PR as ready weeks ago. The open TODOs might be confusing.

Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thank you.
Sorry for the delay, this has slipped through.

@daschuer daschuer merged commit 581803a into mixxxdj:main Oct 17, 2021
@uklotzde uklotzde deleted the track-metadata-sync branch October 23, 2021 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants