mirror of
https://github.com/OpenFactorioServerManager/factorio-server-manager.git
synced 2024-12-31 03:11:17 +02:00
fixed bug in toggling mods issue #23
This commit is contained in:
parent
6e1dedbe03
commit
9a499d0194
@ -69,6 +69,7 @@ func ToggleMod(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
err = m.toggleMod(modName)
|
err = m.toggleMod(modName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
resp.Success = false
|
||||||
resp.Data = fmt.Sprintf("Could not toggle mod: %s error: %s", modName, err)
|
resp.Data = fmt.Sprintf("Could not toggle mod: %s error: %s", modName, err)
|
||||||
if err := json.NewEncoder(w).Encode(resp); err != nil {
|
if err := json.NewEncoder(w).Encode(resp); err != nil {
|
||||||
log.Printf("Error in list mods: %s", err)
|
log.Printf("Error in list mods: %s", err)
|
||||||
|
7
mods.go
7
mods.go
@ -111,7 +111,11 @@ func (m *ModList) toggleMod(name string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if found {
|
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)
|
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)
|
err := ioutil.WriteFile(modListFile, b, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error writing to mod-list.json file: %s", err)
|
log.Printf("Error writing to mod-list.json file: %s", err)
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user