fixed bug in toggling mods issue #23

This commit is contained in:
majormjr 2016-05-03 13:31:07 -04:00
parent 6e1dedbe03
commit 9a499d0194
2 changed files with 7 additions and 1 deletions

View File

@ -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)

View File

@ -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