Skip to content

Commit

Permalink
fix cache cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
XORbit01 committed Oct 18, 2024
1 parent c9271c9 commit 17ba98d
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions server/player/db/music.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,12 @@ func (d *Db) FilterMusic(query string) ([]Music, error) {
func (d *Db) CleanCache() error {
// Delete music thats not in playlist
_, err := d.db.Exec(
`DELETE FROM music WHERE hash NOT IN (SELECT hash FROM playlist)`,
`DELETE FROM music WHERE hash NOT IN (SELECT hash FROM music INNER JOIN music_playlist ON music.name = music_playlist.music_name)`,
)
return err
}

func (d *Db) GetCachedMusics() ([]Music, error) {
// join table
rows, err := d.db.Query(
`select * from music where hash not in (SELECT hash FROM music INNER JOIN music_playlist ON music.name = music_playlist.music_name)`,
)
Expand Down

0 comments on commit 17ba98d

Please sign in to comment.