fixed bug where empty savefile is submitted

This commit is contained in:
majormjr 2016-04-29 19:20:47 -04:00
parent ed49b1137f
commit 8f7995d2e5

View File

@ -454,6 +454,7 @@ func StartServer(w http.ResponseWriter, r *http.Request) {
log.Printf("Error in starting factorio server handler body: %s", err)
return
}
log.Printf("Starting Factorio server with settings: %v", string(body))
err = json.Unmarshal(body, &FactorioServ)
@ -462,6 +463,16 @@ func StartServer(w http.ResponseWriter, r *http.Request) {
return
}
// Check if savefile was submitted with request to start server.
if FactorioServ.Savefile == "" {
log.Printf("Error starting Factorio server: %s", err)
resp.Data = fmt.Sprintf("Error starting Factorio server: %s", err)
if err := json.NewEncoder(w).Encode(resp); err != nil {
log.Printf("Error encoding config file JSON reponse: ", err)
}
return
}
go func() {
err = FactorioServ.Run()
if err != nil {