From 9a499d01941c3526bea248f45b2d42a43e0245df Mon Sep 17 00:00:00 2001 From: majormjr Date: Tue, 3 May 2016 13:31:07 -0400 Subject: [PATCH] fixed bug in toggling mods issue #23 --- handlers.go | 1 + mods.go | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/handlers.go b/handlers.go index b6b4271..7c91a22 100644 --- a/handlers.go +++ b/handlers.go @@ -69,6 +69,7 @@ func ToggleMod(w http.ResponseWriter, r *http.Request) { err = m.toggleMod(modName) if err != nil { + resp.Success = false resp.Data = fmt.Sprintf("Could not toggle mod: %s error: %s", modName, err) if err := json.NewEncoder(w).Encode(resp); err != nil { log.Printf("Error in list mods: %s", err) diff --git a/mods.go b/mods.go index b111a2d..17dab67 100644 --- a/mods.go +++ b/mods.go @@ -111,7 +111,11 @@ func (m *ModList) toggleMod(name string) error { } if found { - m.save() + err := m.save() + if err != nil { + log.Printf("Error saving changes to mod-list-.json file: %s", err) + return err + } log.Printf("Mod: %s was toggled to %v", name, status) } @@ -127,6 +131,7 @@ func (m ModList) save() error { err := ioutil.WriteFile(modListFile, b, 0644) if err != nil { log.Printf("Error writing to mod-list.json file: %s", err) + return err } return nil