mirror of
https://github.com/OpenFactorioServerManager/factorio-server-manager.git
synced 2024-12-29 02:57:24 +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)
|
||||
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)
|
||||
|
7
mods.go
7
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
|
||||
|
Loading…
Reference in New Issue
Block a user