Commit 6486206c authored by Agate's avatar Agate 💬

Merge branch '1011-skipped-not-prunable' into 'master'

Fix #1011: Ensure tracks linked to skipped upload can be pruned

See merge request funkwhale/funkwhale!1117
parents 8cd40699 c7a3dd9d
......@@ -817,9 +817,15 @@ def get_prunable_tracks(
Returns a list of tracks with no associated uploads,
excluding the one that were listened/favorited/included in playlists.
"""
purgeable_tracks_with_upload = (
models.Upload.objects.exclude(track=None)
.filter(import_status="skipped")
.values("track")
)
queryset = models.Track.objects.all()
queryset = queryset.filter(uploads__isnull=True)
queryset = queryset.filter(
Q(uploads__isnull=True) | Q(pk__in=purgeable_tracks_with_upload)
)
if exclude_favorites:
queryset = queryset.filter(track_favorites__isnull=True)
if exclude_playlists:
......
......@@ -867,6 +867,8 @@ def test_clean_transcoding_cache(preferences, now, factories):
def test_get_prunable_tracks(factories):
prunable_track = factories["music.Track"]()
# track is still prunable if it has a skipped upload linked to it
factories["music.Upload"](import_status="skipped", track=prunable_track)
# non prunable tracks
factories["music.Upload"]()
factories["favorites.TrackFavorite"]()
......
Ensure tracks linked to skipped upload can be pruned (#1011)
Markdown is supported
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