Skip to content
Snippets Groups Projects
Commit b9b1e1e2 authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Merge branch '772-skipped-release' into 'develop'

Fix #772: Prevent skipping on file import if album_mbid is different

Closes #772

See merge request funkwhale/funkwhale!694
parents d5712ea2 31227b86
No related branches found
No related tags found
No related merge requests found
...@@ -431,9 +431,10 @@ def _get_track(data): ...@@ -431,9 +431,10 @@ def _get_track(data):
artist_mbid = data.get("musicbrainz_artistid", None) artist_mbid = data.get("musicbrainz_artistid", None)
artist_fid = data.get("artist_fid", None) artist_fid = data.get("artist_fid", None)
artist_name = data["artist"] artist_name = data["artist"]
query = Q(name__iexact=artist_name)
if artist_mbid: if artist_mbid:
query |= Q(mbid=artist_mbid) query = Q(mbid=artist_mbid)
else:
query = Q(name__iexact=artist_name)
if artist_fid: if artist_fid:
query |= Q(fid=artist_fid) query |= Q(fid=artist_fid)
defaults = { defaults = {
...@@ -476,9 +477,12 @@ def _get_track(data): ...@@ -476,9 +477,12 @@ def _get_track(data):
# get / create album # get / create album
album_title = data["album"] album_title = data["album"]
album_fid = data.get("album_fid", None) album_fid = data.get("album_fid", None)
query = Q(title__iexact=album_title, artist=album_artist)
if album_mbid: if album_mbid:
query |= Q(mbid=album_mbid) query = Q(mbid=album_mbid)
else:
query = Q(title__iexact=album_title, artist=album_artist)
if album_fid: if album_fid:
query |= Q(fid=album_fid) query |= Q(fid=album_fid)
defaults = { defaults = {
......
...@@ -133,6 +133,29 @@ def test_can_create_track_from_file_metadata_fid_existing_album_artist( ...@@ -133,6 +133,29 @@ def test_can_create_track_from_file_metadata_fid_existing_album_artist(
assert track.artist == artist assert track.artist == artist
def test_can_create_track_from_file_metadata_distinct_release_mbid(factories):
"""Cf https://dev.funkwhale.audio/funkwhale/funkwhale/issues/772"""
artist = factories["music.Artist"]()
album = factories["music.Album"](artist=artist)
track = factories["music.Track"](album=album, artist=artist)
metadata = {
"artist": artist.name,
"album": album.title,
"title": track.title,
"track_number": 4,
"fid": "https://hello",
"musicbrainz_artistid": artist.mbid,
"musicbrainz_albumid": str(uuid.uuid4()),
}
new_track = tasks.get_track_from_import_metadata(metadata)
# the returned track should be different from the existing one, and mapped
# to a new album, because the albumid is different
assert new_track.album != album
assert new_track != track
def test_can_create_track_from_file_metadata_federation(factories, mocker, r_mock): def test_can_create_track_from_file_metadata_federation(factories, mocker, r_mock):
metadata = { metadata = {
"artist": "Artist", "artist": "Artist",
......
Prevent skipping on file import if album_mbid is different (#772)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment