backend check for save files exist

This commit is contained in:
Mitch Roote 2021-01-30 22:12:24 -05:00
parent 61cd0cbe03
commit 8357027552

View File

@ -3,6 +3,7 @@ package factorio
import (
"bufio"
"encoding/json"
"errors"
"io"
"io/ioutil"
"log"
@ -230,6 +231,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