Import fails for some tracks with 'get() returned more than one Album -- it returned 2!'
Steps to reproduce
- Import one of the impacted tracks
What happens?
Import fails
What is expected?
Import should not fail ^^
Context
Relevant log:
Jul 11 17:32:33 funkwhale celery[2351]: [2018-07-11 15:32:33,870: ERROR/ForkPoolWorker-1] [Import Job 454] Error during import: get() returned more than one Album -- it returned 2!
Jul 11 17:32:34 funkwhale celery[2351]: [2018-07-11 15:32:34,095: ERROR/ForkPoolWorker-1] Task ImportJob.run[8c4f7360-0467-4df1-bb6d-a16bcb17bb85] raised unexpected: MultipleObjectsReturned('get() returned more than one Album -- it returned 2!',)
Jul 11 17:32:34 funkwhale celery[2351]: Traceback (most recent call last):
Jul 11 17:32:34 funkwhale celery[2351]: File "/usr/local/lib/python3.5/dist-packages/celery/app/trace.py", line 375, in trace_task
Jul 11 17:32:34 funkwhale celery[2351]: R = retval = fun(*args, **kwargs)
Jul 11 17:32:34 funkwhale celery[2351]: File "/usr/local/lib/python3.5/dist-packages/celery/app/trace.py", line 632, in __protected_call__
Jul 11 17:32:34 funkwhale celery[2351]: return self.run(*args, **kwargs)
Jul 11 17:32:34 funkwhale celery[2351]: File "/srv/funkwhale/api/funkwhale_api/taskapp/celery.py", line 43, in inner
Jul 11 17:32:34 funkwhale celery[2351]: return function(*args, **kwargs)
Jul 11 17:32:34 funkwhale celery[2351]: File "/srv/funkwhale/api/funkwhale_api/music/tasks.py", line 259, in import_job_run
Jul 11 17:32:34 funkwhale celery[2351]: self.retry(exc=exc, countdown=30, max_retries=3)
Jul 11 17:32:34 funkwhale celery[2351]: File "/usr/local/lib/python3.5/dist-packages/celery/app/task.py", line 668, in retry
Jul 11 17:32:34 funkwhale celery[2351]: raise_with_context(exc)
Jul 11 17:32:34 funkwhale celery[2351]: File "/srv/funkwhale/api/funkwhale_api/music/tasks.py", line 254, in import_job_run
Jul 11 17:32:34 funkwhale celery[2351]: tf = _do_import(import_job, use_acoustid=use_acoustid)
Jul 11 17:32:34 funkwhale celery[2351]: File "/srv/funkwhale/api/funkwhale_api/music/tasks.py", line 115, in _do_import
Jul 11 17:32:34 funkwhale celery[2351]: track = audiofile_tasks.import_track_data_from_path(import_job.audio_file.path)
Jul 11 17:32:34 funkwhale celery[2351]: File "/usr/lib/python3.5/contextlib.py", line 30, in inner
Jul 11 17:32:34 funkwhale celery[2351]: return func(*args, **kwds)
Jul 11 17:32:34 funkwhale celery[2351]: File "/srv/funkwhale/api/funkwhale_api/providers/audiofile/tasks.py", line 38, in import_track_data_from_path
Jul 11 17:32:34 funkwhale celery[2351]: )[0]
Jul 11 17:32:34 funkwhale celery[2351]: File "/usr/local/lib/python3.5/dist-packages/django/db/models/manager.py", line 82, in manager_method
Jul 11 17:32:34 funkwhale celery[2351]: return getattr(self.get_queryset(), name)(*args, **kwargs)
Jul 11 17:32:34 funkwhale celery[2351]: File "/usr/local/lib/python3.5/dist-packages/django/db/models/query.py", line 487, in get_or_create
Jul 11 17:32:34 funkwhale celery[2351]: return self.get(**lookup), False
Jul 11 17:32:34 funkwhale celery[2351]: File "/usr/local/lib/python3.5/dist-packages/cacheops/query.py", line 354, in get
Jul 11 17:32:34 funkwhale celery[2351]: return qs._no_monkey.get(qs, *args, **kwargs)
Jul 11 17:32:34 funkwhale celery[2351]: File "/usr/local/lib/python3.5/dist-packages/django/db/models/query.py", line 407, in get
Jul 11 17:32:34 funkwhale celery[2351]: (self.model._meta.object_name, num)
Jul 11 17:32:34 funkwhale celery[2351]: funkwhale_api.music.models.MultipleObjectsReturned: get() returned more than one Album -- it returned 2!