Skip to content
Snippets Groups Projects
Unverified Commit c7a3dd9d authored by Agate's avatar Agate :speech_balloon:
Browse files

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

parent 8cd40699
No related branches found
No related tags found
No related merge requests found
...@@ -817,9 +817,15 @@ def get_prunable_tracks( ...@@ -817,9 +817,15 @@ def get_prunable_tracks(
Returns a list of tracks with no associated uploads, Returns a list of tracks with no associated uploads,
excluding the one that were listened/favorited/included in playlists. 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 = 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: if exclude_favorites:
queryset = queryset.filter(track_favorites__isnull=True) queryset = queryset.filter(track_favorites__isnull=True)
if exclude_playlists: if exclude_playlists:
......
...@@ -867,6 +867,8 @@ def test_clean_transcoding_cache(preferences, now, factories): ...@@ -867,6 +867,8 @@ def test_clean_transcoding_cache(preferences, now, factories):
def test_get_prunable_tracks(factories): def test_get_prunable_tracks(factories):
prunable_track = factories["music.Track"]() 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 # non prunable tracks
factories["music.Upload"]() factories["music.Upload"]()
factories["favorites.TrackFavorite"]() factories["favorites.TrackFavorite"]()
......
Ensure tracks linked to skipped upload can be pruned (#1011)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment