Fixed some bugs

* Fixed bug with sync
* Made default list of game randomized
* Added get all games ordered
* Added air for live reload
This commit is contained in:
2022-04-23 11:40:54 +02:00
parent f9d6c24a97
commit 58ff8a64cc
7 changed files with 76 additions and 8 deletions

View File

@@ -74,7 +74,8 @@ func SetupRestServer(frontend embed.FS, swagger embed.FS) {
musicGroup.GET("list", music.GetPlayedSongs)
musicGroup.GET("next", music.GetNextSong)
musicGroup.GET("previous", music.GetPreviousSong)
musicGroup.GET("all", music.GetAllGames)
musicGroup.GET("all", music.GetAllGamesRandom)
musicGroup.GET("all/order", music.GetAllGames)
musicGroup.GET("all/random", music.GetAllGamesRandom)
musicGroup.PUT("played", music.PutPlayed)
musicGroup.GET("addQue", music.AddLatestToQue)

View File

@@ -40,7 +40,7 @@ func SyncGames() {
innerFiles, err := ioutil.ReadDir(path)
if err != nil {
log.Fatal(err)
log.Println(err)
}
id := -1
for _, song := range innerFiles {
@@ -114,7 +114,7 @@ func checkSongs(gameDir string, gameId int) {
files, err := ioutil.ReadDir(gameDir)
if err != nil {
log.Fatal(err)
log.Println(err)
}
for _, entry := range files {
path := gameDir + entry.Name()
@@ -143,10 +143,12 @@ func checkBrokenSongs() {
if err != nil {
//File not found
brokenSongs = append(brokenSongs, song)
}
err = openFile.Close()
if err != nil {
log.Fatal(err)
fmt.Printf("song broken: %v", song.Path)
} else {
err = openFile.Close()
if err != nil {
log.Println(err)
}
}
}
db.RemoveBrokenSongs(brokenSongs)