Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Philipp Wolfer
funkwhale
Commits
c7a3dd9d
Unverified
Commit
c7a3dd9d
authored
May 07, 2020
by
Agate
💬
Browse files
Fix
#1011
: Ensure tracks linked to skipped upload can be pruned
parent
8cd40699
Changes
3
Hide whitespace changes
Inline
Side-by-side
api/funkwhale_api/music/tasks.py
View file @
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
:
...
...
api/tests/music/test_tasks.py
View file @
c7a3dd9d
...
...
@@ -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"
]()
...
...
changes/changelog.d/1011.bugfix
0 → 100644
View file @
c7a3dd9d
Ensure tracks linked to skipped upload can be pruned (#1011)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment