mirror of
https://github.com/OpenFactorioServerManager/factorio-server-manager.git
synced 2025-02-03 13:21:25 +02:00
commit
691e924269
@ -462,7 +462,8 @@ func CreateSaveHandler(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
cmdOut, err := createSave(saveName)
|
||||
saveFile := filepath.Join(config.FactorioSavesDir, saveName)
|
||||
cmdOut, err := createSave(saveFile)
|
||||
if err != nil {
|
||||
log.Printf("Error creating save: %s", err)
|
||||
resp.Data = "Error creating savefile."
|
||||
|
@ -26,9 +26,14 @@ type FactorioServer struct {
|
||||
StdIn io.WriteCloser
|
||||
}
|
||||
|
||||
func createSave(saveName string) (string, error) {
|
||||
args := []string{"--create", saveName}
|
||||
func createSave(filePath string) (string, error) {
|
||||
err := os.MkdirAll(filepath.Base(filePath), 0755)
|
||||
if err != nil {
|
||||
log.Printf("Error in creating Factorio save: %s", err)
|
||||
return "", err
|
||||
}
|
||||
|
||||
args := []string{"--create", filePath}
|
||||
cmdOutput, err := exec.Command(config.FactorioBinary, args...).Output()
|
||||
if err != nil {
|
||||
log.Printf("Error in creating Factorio save: %s", err)
|
||||
|
Loading…
x
Reference in New Issue
Block a user