Added check if game not found

This commit is contained in:
2024-07-31 21:57:02 +02:00
parent 51a74a9ed1
commit 5616b51512
2 changed files with 15 additions and 7 deletions

View File

@@ -72,7 +72,7 @@ func GetRandomSongLowChance() string {
}
}
}
song := getSongFromList(games)
song := getSongFromList(listOfGames)
lastFetched = song
return song.Path
@@ -93,7 +93,13 @@ func GetRandomSongClassic() string {
var song models.SongData
for !songFound {
song = listOfAllSongs[rand.Intn(len(listOfAllSongs))]
gameData := db.GetGameById(song.GameId)
gameData, err := db.GetGameById(song.GameId)
if err != nil {
db.RemoveBrokenSong(song)
log.Println("Song not found, song '" + song.SongName + "' deleted from game '" + gameData.GameName + "' FileName: " + song.FileName)
continue
}
//Check if file exists and open
openFile, err := os.Open(song.Path)