From 6d9c0a713e5449d63820bbf63409fd39e15c0f53 Mon Sep 17 00:00:00 2001 From: chulo Date: Wed, 16 Sep 2020 10:57:54 -0300 Subject: [PATCH] Fix settings not read from config file (thx @cizara) --- internal/lyricfier/general.go | 6 ++++-- internal/lyricfier/server.go | 2 +- internal/lyricfier/spotify_windows.go | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/internal/lyricfier/general.go b/internal/lyricfier/general.go index 028f36e..24d0f16 100644 --- a/internal/lyricfier/general.go +++ b/internal/lyricfier/general.go @@ -130,12 +130,14 @@ func (h *Main) ReadSettings() { h.AppData.Settings = defaultSettings() return } - err = json.Unmarshal(val, h.AppData.Settings) + var p *Settings + err = json.Unmarshal(val, &p) if err != nil { - fmt.Printf("error umarshalling saved settings %v\n", err) + fmt.Printf("error umarshalling saved settings: %v\n", err) h.AppData.Settings = defaultSettings() return } + h.AppData.Settings = p; } func (h *Main) Search(done chan *SearchResult, artist string, title string) { diff --git a/internal/lyricfier/server.go b/internal/lyricfier/server.go index 542524f..4df920d 100644 --- a/internal/lyricfier/server.go +++ b/internal/lyricfier/server.go @@ -84,7 +84,7 @@ func (h *Server) routes(hub *Hub) { } settings, err := json.Marshal(s) if err != nil { - fmt.Printf("could not marshal config json: %v\n", err) + fmt.Printf("Could not marshal config json: %v\n", err) return c.JSON(http.StatusInternalServerError, h.appData) } diff --git a/internal/lyricfier/spotify_windows.go b/internal/lyricfier/spotify_windows.go index ea8f805..8aeaa53 100644 --- a/internal/lyricfier/spotify_windows.go +++ b/internal/lyricfier/spotify_windows.go @@ -5,11 +5,11 @@ package lyricfier import ( "encoding/csv" "fmt" - "path/filepath" - "os" "golang.org/x/text/encoding/charmap" "log" + "os" "os/exec" + "path/filepath" "strings" "syscall" "time"