Merge branch 'fix-import-index-violation' into 'develop'

Skip importing files that cause index violations

See merge request funkwhale/funkwhale!1236
This commit is contained in:
Agate 2020-11-19 22:27:03 +01:00
commit 8c69b68806
1 changed files with 8 additions and 0 deletions

View File

@ -17,6 +17,7 @@ from django.core.files import File
from django.core.management import call_command
from django.core.management.base import BaseCommand, CommandError
from django.db.models import Q
from django.db.utils import IntegrityError
from django.utils import timezone
from rest_framework import serializers
@ -832,6 +833,13 @@ def check_upload(stdout, upload):
except serializers.ValidationError as e:
stdout.write(" Invalid metadata: {}".format(e))
return
except IntegrityError:
stdout.write(
" Duplicate key violation for metadata. Skipping...\n{}".format(
upload.source
)
)
return
else:
upload.checksum = checksum
upload.save(update_fields=["checksum"])