and again
This commit is contained in:
parent
766419aec2
commit
bc0a5f3c00
|
@ -155,17 +155,15 @@ def check_succefull_migration(apps, schema_editor):
|
||||||
actor.playlists.count()
|
actor.playlists.count()
|
||||||
+ actor.libraries.filter(channel__isnull=False).count()
|
+ actor.libraries.filter(channel__isnull=False).count()
|
||||||
)
|
)
|
||||||
actor_playlist_lib = actor.playlists.filter(library__isnull=False).count()
|
|
||||||
|
|
||||||
if actor.playlists.count() != actor_playlist_lib:
|
|
||||||
raise Exception(
|
|
||||||
f"Incoherent playlist database state : all playlists do not have lib or too many libs\
|
|
||||||
actor_playlist_lib = {actor_playlist_lib} actor.playlists.count()={actor.playlists.count()}"
|
|
||||||
)
|
|
||||||
|
|
||||||
if actor.name == "service" or not federation_utils.is_local(actor.fid):
|
if actor.name == "service" or not federation_utils.is_local(actor.fid):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
elif actor.playlists.filter(library__isnull=True).count() > 0:
|
||||||
|
raise Exception(
|
||||||
|
f"Incoherent playlist database state : all playlists do not have lib or too many libs\
|
||||||
|
actor.playlists.filter(library__isnull=True).count() = {actor.playlists.filter(library__isnull=True).count()} "
|
||||||
|
)
|
||||||
elif actor.libraries.count() - 3 != not_build_in_libs or (
|
elif actor.libraries.count() - 3 != not_build_in_libs or (
|
||||||
hasattr(actor, "channel") and actor.libraries.count() > 1
|
hasattr(actor, "channel") and actor.libraries.count() > 1
|
||||||
):
|
):
|
||||||
|
|
|
@ -3,6 +3,7 @@ from django.db import migrations, models, transaction
|
||||||
from funkwhale_api.federation import utils as federation_utils
|
from funkwhale_api.federation import utils as federation_utils
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
import uuid
|
import uuid
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
def add_uploads_to_pl_library(playlist, library):
|
def add_uploads_to_pl_library(playlist, library):
|
||||||
|
@ -15,9 +16,13 @@ def add_uploads_to_pl_library(playlist, library):
|
||||||
def create_playlist_libraries(apps, schema_editor):
|
def create_playlist_libraries(apps, schema_editor):
|
||||||
Playlist = apps.get_model("playlists", "Playlist")
|
Playlist = apps.get_model("playlists", "Playlist")
|
||||||
Library = apps.get_model("music", "Library")
|
Library = apps.get_model("music", "Library")
|
||||||
|
Actor = apps.get_model("federation", "Actor")
|
||||||
|
playlist_with_lib_count = 0
|
||||||
|
|
||||||
for playlist in Playlist.objects.all():
|
for playlist in Playlist.objects.all():
|
||||||
if not federation_utils.is_local(playlist.fid):
|
if not federation_utils.is_local(playlist.fid) or not federation_utils.is_local(
|
||||||
|
playlist.actor.fid
|
||||||
|
):
|
||||||
continue
|
continue
|
||||||
library = playlist.library
|
library = playlist.library
|
||||||
if not library:
|
if not library:
|
||||||
|
@ -46,6 +51,18 @@ def create_playlist_libraries(apps, schema_editor):
|
||||||
to enforce one lib per playlist"
|
to enforce one lib per playlist"
|
||||||
)
|
)
|
||||||
raise e
|
raise e
|
||||||
|
playlist_with_lib_count = playlist_with_lib_count + 1
|
||||||
|
local_actors = Actor.objects.filter(domain_id=settings.FEDERATION_HOSTNAME)
|
||||||
|
|
||||||
|
if (
|
||||||
|
Library.objects.filter(
|
||||||
|
playlist__isnull=False, actor__in=local_actors
|
||||||
|
).count()
|
||||||
|
!= playlist_with_lib_count
|
||||||
|
):
|
||||||
|
raise Exception(
|
||||||
|
"Should have the same amount of local playlist and libraries with playlist"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
Loading…
Reference in New Issue