fix: make server path creation more robust
This commit is contained in:
24
pkg/server/server.go
Normal file
24
pkg/server/server.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user