fix: make server path creation more robust

This commit is contained in:
2021-10-02 22:30:08 +02:00
parent db5cbfa992
commit 48290aa316
2 changed files with 34 additions and 6 deletions

24
pkg/server/server.go Normal file
View File

@ -0,0 +1,24 @@
package server
import (
"os"
"path"
"coopcloud.tech/abra/pkg/config"
"github.com/sirupsen/logrus"
)
// CreateServerDir creates a server directory under ~/.abra.
func CreateServerDir(serverName string) error {
serverPath := path.Join(config.ABRA_DIR, "servers", serverName)
if err := os.Mkdir(serverPath, 0755); err != nil {
if !os.IsExist(err) {
return err
}
logrus.Infof("'%s' already exists, moving on...", serverPath)
}
return nil
}