See #542: fixed issue with empty actor during upgrade script
This commit is contained in:
parent
e1628a33d2
commit
02006270cd
|
@ -71,7 +71,15 @@ def update_uploads(libraries_by_user, stdout):
|
||||||
|
|
||||||
def update_orphan_uploads(open_api, stdout):
|
def update_orphan_uploads(open_api, stdout):
|
||||||
privacy_level = "everyone" if open_api else "instance"
|
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(
|
library, _ = models.Library.objects.get_or_create(
|
||||||
name="default",
|
name="default",
|
||||||
actor=first_superuser.actor,
|
actor=first_superuser.actor,
|
||||||
|
|
|
@ -285,7 +285,7 @@ def create_actor(user):
|
||||||
args["private_key"] = private.decode("utf-8")
|
args["private_key"] = private.decode("utf-8")
|
||||||
args["public_key"] = public.decode("utf-8")
|
args["public_key"] = public.decode("utf-8")
|
||||||
|
|
||||||
return federation_models.Actor.objects.create(**args)
|
return federation_models.Actor.objects.create(user=user, **args)
|
||||||
|
|
||||||
|
|
||||||
@receiver(ldap_populate_user)
|
@receiver(ldap_populate_user)
|
||||||
|
|
|
@ -189,10 +189,14 @@ then run the migrations script.
|
||||||
|
|
||||||
On docker-setups::
|
On docker-setups::
|
||||||
|
|
||||||
|
# if you missed this one from a previous upgrade
|
||||||
|
docker-compose run --rm api python manage.py script create_actors --no-input
|
||||||
docker-compose run --rm api python manage.py script migrate_to_user_libraries --no-input
|
docker-compose run --rm api python manage.py script migrate_to_user_libraries --no-input
|
||||||
|
|
||||||
On non docker-setups::
|
On non docker-setups::
|
||||||
|
|
||||||
|
# if you missed this one from a previous upgrade
|
||||||
|
python api/manage.py script create_actors --no-input
|
||||||
python api/manage.py script migrate_to_user_libraries --no-input
|
python api/manage.py script migrate_to_user_libraries --no-input
|
||||||
|
|
||||||
If the scripts ends without errors, you're instance should be updated and ready to use :)
|
If the scripts ends without errors, you're instance should be updated and ready to use :)
|
||||||
|
|
Loading…
Reference in New Issue