Commit 8c69b688 authored by Agate's avatar Agate 💬
Browse files

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

Skip importing files that cause index violations

See merge request funkwhale/funkwhale!1236
parents fdf76fb1 d4160f86
...@@ -17,6 +17,7 @@ from django.core.files import File ...@@ -17,6 +17,7 @@ from django.core.files import File
from django.core.management import call_command from django.core.management import call_command
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from django.db.models import Q from django.db.models import Q
from django.db.utils import IntegrityError
from django.utils import timezone from django.utils import timezone
from rest_framework import serializers from rest_framework import serializers
...@@ -832,6 +833,13 @@ def check_upload(stdout, upload): ...@@ -832,6 +833,13 @@ def check_upload(stdout, upload):
except serializers.ValidationError as e: except serializers.ValidationError as e:
stdout.write(" Invalid metadata: {}".format(e)) stdout.write(" Invalid metadata: {}".format(e))
return return
except IntegrityError:
stdout.write(
" Duplicate key violation for metadata. Skipping...\n{}".format(
upload.source
)
)
return
else: else:
upload.checksum = checksum upload.checksum = checksum
upload.save(update_fields=["checksum"]) upload.save(update_fields=["checksum"])
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment