mirror of
https://github.com/OpenFactorioServerManager/factorio-server-manager.git
synced 2025-02-03 13:21:25 +02:00
Moved createSave function to saves.go, changed permissions when creating server-settings.json file to remove executable permissions
This commit is contained in:
parent
2e1945014b
commit
e1054bd816
@ -46,25 +46,6 @@ type FactorioServerSettings struct {
|
||||
Admins []string `json:"admins"`
|
||||
}
|
||||
|
||||
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)
|
||||
return "", err
|
||||
}
|
||||
|
||||
result := string(cmdOutput)
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func initFactorio() *FactorioServer {
|
||||
f := FactorioServer{}
|
||||
|
||||
@ -101,7 +82,7 @@ func (f *FactorioServer) Run() error {
|
||||
if err != nil {
|
||||
log.Println("Failed to marshal FactorioServerSettings: ", err)
|
||||
} else {
|
||||
ioutil.WriteFile(filepath.Join(config.FactorioDir, "server-settings.json"), data, 0755)
|
||||
ioutil.WriteFile(filepath.Join(config.FactorioDir, "server-settings.json"), data, 0644)
|
||||
}
|
||||
|
||||
args := []string{
|
||||
|
22
src/saves.go
22
src/saves.go
@ -3,7 +3,9 @@ package main
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"time"
|
||||
)
|
||||
@ -53,3 +55,23 @@ func (s *Save) remove() error {
|
||||
|
||||
return os.Remove(filepath.Join(config.FactorioSavesDir, s.Name))
|
||||
}
|
||||
|
||||
// Create savefiles for Factorio
|
||||
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)
|
||||
return "", err
|
||||
}
|
||||
|
||||
result := string(cmdOutput)
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user