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
This commit is contained in:
commit
b9b1e1e26a
|
@ -431,9 +431,10 @@ def _get_track(data):
|
|||
artist_mbid = data.get("musicbrainz_artistid", None)
|
||||
artist_fid = data.get("artist_fid", None)
|
||||
artist_name = data["artist"]
|
||||
query = Q(name__iexact=artist_name)
|
||||
if artist_mbid:
|
||||
query |= Q(mbid=artist_mbid)
|
||||
query = Q(mbid=artist_mbid)
|
||||
else:
|
||||
query = Q(name__iexact=artist_name)
|
||||
if artist_fid:
|
||||
query |= Q(fid=artist_fid)
|
||||
defaults = {
|
||||
|
@ -476,9 +477,12 @@ def _get_track(data):
|
|||
# get / create album
|
||||
album_title = data["album"]
|
||||
album_fid = data.get("album_fid", None)
|
||||
query = Q(title__iexact=album_title, artist=album_artist)
|
||||
|
||||
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:
|
||||
query |= Q(fid=album_fid)
|
||||
defaults = {
|
||||
|
|
|
@ -133,6 +133,29 @@ def test_can_create_track_from_file_metadata_fid_existing_album_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):
|
||||
metadata = {
|
||||
"artist": "Artist",
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Prevent skipping on file import if album_mbid is different (#772)
|
Loading…
Reference in New Issue