Fixed some small bugs that were still present

This commit is contained in:
2024-08-15 20:12:29 +02:00
parent 3438ae9e45
commit da2829dbe2
4 changed files with 24 additions and 16 deletions

View File

@@ -103,7 +103,7 @@ func GetRandomSongClassic() string {
//Check if file exists and open
openFile, err := os.Open(song.Path)
if err != nil || gameData.Path+"/"+song.FileName != song.Path {
if err != nil || gameData.Path+song.FileName != song.Path {
//File not found
db.RemoveBrokenSong(song)
log.Println("Song not found, song '" + song.SongName + "' deleted from game '" + gameData.GameName + "' FileName: " + song.FileName)
@@ -232,12 +232,21 @@ func getSongFromList(games []models.GameData) models.SongData {
var song models.SongData
for !songFound {
game := getRandomGame(games)
log.Println("game = ", game)
songs := db.FindSongsFromGame(game.Id)
log.Println("songs = ", songs)
if len(songs) == 0 {
continue
}
song = songs[rand.Intn(len(songs))]
log.Println("song = ", song)
//Check if file exists and open
openFile, err := os.Open(song.Path)
if err != nil || game.Path+"/"+song.FileName != song.Path {
log.Println("game.Path+song.FileName: ", game.Path+song.FileName)
log.Println("song.Path: ", song.Path)
log.Println("game.Path+song.FileName != song.Path: ", game.Path+song.FileName != song.Path)
if err != nil || game.Path+song.FileName != song.Path {
//File not found
db.RemoveBrokenSong(song)
log.Println("Song not found, song '" + song.SongName + "' deleted from game '" + game.GameName + "' FileName: " + song.FileName)