See #542: fixed issue with empty actor during upgrade script

This commit is contained in:
Eliot Berriot 2018-10-01 19:14:09 +02:00
parent e1628a33d2
commit 02006270cd
No known key found for this signature in database
GPG key ID: DD6965E2476E5C27
3 changed files with 14 additions and 2 deletions

View file

@ -71,7 +71,15 @@ def update_uploads(libraries_by_user, stdout):
def update_orphan_uploads(open_api, stdout):
privacy_level = "everyone" if open_api else "instance"
first_superuser = User.objects.filter(is_superuser=True).order_by("pk").first()
first_superuser = (
User.objects.filter(is_superuser=True)
.exclude(actor=None)
.order_by("pk")
.first()
)
if not first_superuser:
stdout.write("* No superuser found, skipping update orphan uploads")
return
library, _ = models.Library.objects.get_or_create(
name="default",
actor=first_superuser.actor,