mirror of
https://github.com/OpenFactorioServerManager/factorio-server-manager.git
synced 2025-01-04 03:49:23 +02:00
Bescause the working directory is set to where the go executable is running the absolute path should be used when creating a new map.
This commit is contained in:
parent
d788b25a74
commit
86d2cd9158
@ -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…
Reference in New Issue
Block a user