mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-22 17:06:17 +00:00
parent
783e9b5465
commit
1de9e2bf6e
@ -98,6 +98,7 @@ def delete_playlist():
|
||||
if res.user_id != request.user.id and not request.user.admin:
|
||||
return request.error_formatter(50, "You're not allowed to delete a playlist that isn't yours")
|
||||
|
||||
res.tracks.clear()
|
||||
store.remove(res)
|
||||
store.commit()
|
||||
return request.formatter({})
|
||||
|
@ -87,6 +87,10 @@ class FolderManager:
|
||||
for track in store.find(Track, Track.root_folder_id == folder.id):
|
||||
scanner.remove_file(track.path)
|
||||
scanner.finish()
|
||||
|
||||
store.find(StarredFolder, StarredFolder.starred_id == uid).remove()
|
||||
store.find(RatingFolder, RatingFolder.rated_id == uid).remove()
|
||||
|
||||
store.remove(folder)
|
||||
store.commit()
|
||||
|
||||
|
@ -74,6 +74,17 @@ class UserManager:
|
||||
if status != UserManager.SUCCESS:
|
||||
return status
|
||||
|
||||
store.find(StarredFolder, StarredFolder.user_id == uid).remove()
|
||||
store.find(StarredArtist, StarredArtist.user_id == uid).remove()
|
||||
store.find(StarredAlbum, StarredAlbum.user_id == uid).remove()
|
||||
store.find(StarredTrack, StarredTrack.user_id == uid).remove()
|
||||
store.find(RatingFolder, RatingFolder.user_id == uid).remove()
|
||||
store.find(RatingTrack, RatingTrack.user_id == uid).remove()
|
||||
store.find(ChatMessage, ChatMessage.user_id == uid).remove()
|
||||
for playlist in store.find(Playlist, Playlist.user_id == uid):
|
||||
playlist.tracks.clear()
|
||||
store.remove(playlist)
|
||||
|
||||
store.remove(user)
|
||||
store.commit()
|
||||
|
||||
|
@ -102,12 +102,16 @@ class Scanner:
|
||||
|
||||
def finish(self):
|
||||
for album in [ a for a in self.__albums_to_check if not a.tracks.count() ]:
|
||||
self.__store.find(StarredAlbum, StarredAlbum.starred_id == album.id).remove()
|
||||
|
||||
self.__artists_to_check.add(album.artist)
|
||||
self.__store.remove(album)
|
||||
self.__deleted_albums += 1
|
||||
self.__albums_to_check.clear()
|
||||
|
||||
for artist in [ a for a in self.__artists_to_check if not a.albums.count() and not a.tracks.count() ]:
|
||||
self.__store.find(StarredArtist, StarredArtist.starred_id == artist.id).remove()
|
||||
|
||||
self.__store.remove(artist)
|
||||
self.__deleted_artists += 1
|
||||
self.__artists_to_check.clear()
|
||||
@ -118,6 +122,9 @@ class Scanner:
|
||||
continue
|
||||
|
||||
if not folder.tracks.count() and not folder.children.count():
|
||||
self.__store.find(StarredFolder, StarredFolder.starred_id == folder.id).remove()
|
||||
self.__store.find(RatingFolder, RatingFolder.rated_id == folder.id).remove()
|
||||
|
||||
self.__folders_to_check.add(folder.parent)
|
||||
self.__store.remove(folder)
|
||||
|
||||
@ -193,6 +200,11 @@ class Scanner:
|
||||
if not tr:
|
||||
return
|
||||
|
||||
self.__store.find(StarredTrack, StarredTrack.starred_id == tr.id).remove()
|
||||
self.__store.find(RatingTrack, RatingTrack.rated_id == tr.id).remove()
|
||||
self.__store.find(PlaylistTrack, PlaylistTrack.track_id == tr.id).remove()
|
||||
self.__store.find(User, User.last_play_id == tr.id).set(User.last_play_id = None)
|
||||
|
||||
self.__folders_to_check.add(tr.folder)
|
||||
self.__albums_to_check.add(tr.album)
|
||||
self.__artists_to_check.add(tr.artist)
|
||||
|
Loading…
Reference in New Issue
Block a user