mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
fix migrations deleting all playlists
This commit is contained in:
committed by
Mungai Njoroge
parent
ae031014a9
commit
99ec11565c
@@ -0,0 +1,13 @@
|
|||||||
|
# TODO
|
||||||
|
A list of things to do. Feel free to grab one of this and work on it.
|
||||||
|
|
||||||
|
## Clean up old playlist images
|
||||||
|
When playlists are deleted or their images updated, the old
|
||||||
|
images are not deleted.
|
||||||
|
|
||||||
|
Write a function to:
|
||||||
|
- read all images in the playlist image directory and checks unlinked images by comparing the list with the .image property of each property
|
||||||
|
- delete unlinked images
|
||||||
|
|
||||||
|
The function can run on app start up, before periodic checks
|
||||||
|
|
||||||
+1
-2
@@ -26,12 +26,11 @@ api = APIBlueprint("playlists", __name__, url_prefix="/playlists", abp_tags=[tag
|
|||||||
|
|
||||||
PL = SQLitePlaylistMethods
|
PL = SQLitePlaylistMethods
|
||||||
|
|
||||||
|
|
||||||
class SendAllPlaylistsQuery(BaseModel):
|
class SendAllPlaylistsQuery(BaseModel):
|
||||||
no_images: bool = Field(False, description="Whether to include images")
|
no_images: bool = Field(False, description="Whether to include images")
|
||||||
|
|
||||||
|
|
||||||
@api.get("", methods=["GET"])
|
@api.get("")
|
||||||
def send_all_playlists(query: SendAllPlaylistsQuery):
|
def send_all_playlists(query: SendAllPlaylistsQuery):
|
||||||
"""
|
"""
|
||||||
Gets all the playlists.
|
Gets all the playlists.
|
||||||
|
|||||||
+1
-2
@@ -138,9 +138,8 @@ def get_top_results(query: TopResultsQuery):
|
|||||||
|
|
||||||
Returns the top results for the given query.
|
Returns the top results for the given query.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
query = query.q
|
|
||||||
limit = query.limit
|
limit = query.limit
|
||||||
|
query = query.q
|
||||||
|
|
||||||
in_quotes = query_in_quotes(query)
|
in_quotes = query_in_quotes(query)
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ ONLY MODIFY OLD MIGRATIONS FOR BUG FIXES OR ENHANCEMENTS ONLY
|
|||||||
PS: Fuck that! Do what you want.
|
PS: Fuck that! Do what you want.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
from app.db.sqlite.migrations import MigrationManager
|
from app.db.sqlite.migrations import MigrationManager
|
||||||
from app.logger import log
|
from app.logger import log
|
||||||
from app.migrations import v1_3_0, v1_4_9
|
from app.migrations import v1_3_0, v1_4_9
|
||||||
@@ -27,9 +26,7 @@ migrations: list[list[Migration]] = [
|
|||||||
v1_3_0.RemoveAllTracks,
|
v1_3_0.RemoveAllTracks,
|
||||||
v1_3_0.UpdateAppSettingsTable,
|
v1_3_0.UpdateAppSettingsTable,
|
||||||
],
|
],
|
||||||
[
|
[v1_4_9.AddTimestampToFavoritesTable],
|
||||||
v1_4_9.AddTimestampToFavoritesTable
|
|
||||||
]
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@@ -41,8 +38,8 @@ def apply_migrations():
|
|||||||
version = MigrationManager.get_version()
|
version = MigrationManager.get_version()
|
||||||
|
|
||||||
if version != len(migrations):
|
if version != len(migrations):
|
||||||
# run migrations after the previous migration version
|
# INFO: Apply new migrations
|
||||||
for migration in migrations[(version - 1) :]:
|
for migration in migrations[version:]:
|
||||||
for m in migration:
|
for m in migration:
|
||||||
try:
|
try:
|
||||||
m.migrate()
|
m.migrate()
|
||||||
|
|||||||
Reference in New Issue
Block a user