working commit

This commit is contained in:
2026-02-13 15:42:11 +02:00
parent 3750b386b1
commit e72ffda8b1
3 changed files with 24 additions and 19 deletions
+7 -2
View File
@@ -71,6 +71,7 @@ func (srv *Server) SetRundir(dir string) {
func (srv *Server) SetDatadir(dir string) { func (srv *Server) SetDatadir(dir string) {
srv.conf.Database.Basepath = dir srv.conf.Database.Basepath = dir
srv.conf.Storage.Basepath = dir srv.conf.Storage.Basepath = dir
srv.conf.Datadir = dir
} }
func (srv *Server) SetPort(port int64) { func (srv *Server) SetPort(port int64) {
@@ -120,6 +121,7 @@ func (srv *Server) ReadStat() error {
var err error var err error
// Read state file // Read state file
statefilePath := filepath.Join(srv.conf.Datadir, "server.yaml") statefilePath := filepath.Join(srv.conf.Datadir, "server.yaml")
if auxtool.FileExists(statefilePath) {
stateData, err := ioutil.ReadFile(statefilePath) stateData, err := ioutil.ReadFile(statefilePath)
if err == nil { if err == nil {
stat := descr.Server{} stat := descr.Server{}
@@ -129,6 +131,7 @@ func (srv *Server) ReadStat() error {
} }
srv.stat = stat srv.stat = stat
} }
}
return err return err
} }
@@ -156,26 +159,28 @@ func (srv *Server) Build() error {
// Creating datadir // Creating datadir
datadir := srv.conf.Datadir datadir := srv.conf.Datadir
if !auxtool.DirExists(datadir) {
srv.logg.Infof("Creating data directory %s ", datadir) srv.logg.Infof("Creating data directory %s ", datadir)
err = os.MkdirAll(datadir, 0750) err = os.MkdirAll(datadir, 0750)
if err != nil { if err != nil {
return err return err
} }
}
// Read state file // Read state file
srv.logg.Infof("Reading server status") srv.logg.Infof("Reading server status")
err = srv.ReadStat() err = srv.ReadStat()
if err != nil { if err != nil {
return err return err
} }
// Creating database dir // Creating database dir
dbdir := srv.conf.Database.Basepath dbdir := srv.conf.Database.Basepath
if !auxtool.DirExists(dbdir) {
srv.logg.Infof("Creating database directory %s ", dbdir) srv.logg.Infof("Creating database directory %s ", dbdir)
err = os.MkdirAll(dbdir, 0750) err = os.MkdirAll(dbdir, 0750)
if err != nil { if err != nil {
return err return err
} }
}
// Creating database // Creating database
mdb := maindb.NewDatabase(dbdir) mdb := maindb.NewDatabase(dbdir)
srv.logg.Infof("Opening main database") srv.logg.Infof("Opening main database")
+2 -2
View File
@@ -18,7 +18,7 @@ import (
"mstore/app/operator" "mstore/app/operator"
) )
func (cli *Client) CreateGrant(ctx context.Context, hosturi, accountID, operation, pattern string) error { func (cli *Client) CreateGrant(ctx context.Context, hosturi, accountID, right, pattern string) error {
var err error var err error
apiuri, err := setApiPath(hosturi, "/v3/api/grant/create") apiuri, err := setApiPath(hosturi, "/v3/api/grant/create")
@@ -27,7 +27,7 @@ func (cli *Client) CreateGrant(ctx context.Context, hosturi, accountID, operatio
} }
operParams := operator.CreateGrantParams{ operParams := operator.CreateGrantParams{
AccountID: accountID, AccountID: accountID,
Operation: operation, Right: right,
Pattern: pattern, Pattern: pattern,
} }
paramsJson, err := json.Marshal(operParams) paramsJson, err := json.Marshal(operParams)