mirror of
https://github.com/OpenFactorioServerManager/factorio-server-manager.git
synced 2024-12-27 02:43:45 +02:00
Merge pull request #242 from OpenFactorioServerManager/no-existing-save
Display error if server started without save created
This commit is contained in:
commit
29fe0650d3
@ -3,6 +3,7 @@ package factorio
|
||||
import (
|
||||
"bufio"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
@ -229,6 +230,15 @@ func (server *Server) Run() error {
|
||||
ioutil.WriteFile(config.SettingsFile, data, 0644)
|
||||
}
|
||||
|
||||
saves, err := ListSaves(config.FactorioSavesDir)
|
||||
if err != nil {
|
||||
log.Println("Failed to get saves list: ", err)
|
||||
}
|
||||
|
||||
if len(saves) == 0 {
|
||||
return errors.New("No savefile exists on the server")
|
||||
}
|
||||
|
||||
args := []string{}
|
||||
|
||||
//The factorio server refenences its executable-path, since we execute the ld.so file and pass the factorio binary as a parameter
|
||||
|
@ -17,6 +17,10 @@ const Controls = ({serverStatus, updateServerStatus}) => {
|
||||
const { handleSubmit, register, errors } = useForm();
|
||||
|
||||
const startServer = async (data) => {
|
||||
if(saves.length === 1 && saves[0].name === "Load Latest") {
|
||||
window.flash("Save must be created before starting server", "red");
|
||||
return;
|
||||
}
|
||||
await server.start(data.ip, parseInt(data.port), data.save);
|
||||
await updateServerStatus();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user