Check space dir existence before creating new

This commit is contained in:
mcrakhman 2022-12-03 13:23:14 +01:00 committed by Mikhail Iudin
parent 5098daf152
commit 78f67d221c
No known key found for this signature in database
GPG Key ID: FAAAA8BAABDFF1C0

View File

@ -8,6 +8,7 @@ import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/treechangeproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/treechangeproto"
"go.uber.org/zap" "go.uber.org/zap"
"os"
"path" "path"
"time" "time"
) )
@ -30,6 +31,11 @@ type spaceStorage struct {
func newSpaceStorage(rootPath string, spaceId string) (store spacestorage.SpaceStorage, err error) { func newSpaceStorage(rootPath string, spaceId string) (store spacestorage.SpaceStorage, err error) {
log.With(zap.String("id", spaceId)).Debug("space storage opening with new") log.With(zap.String("id", spaceId)).Debug("space storage opening with new")
dbPath := path.Join(rootPath, spaceId) dbPath := path.Join(rootPath, spaceId)
if _, err = os.Stat(dbPath); err != nil {
err = spacestorage.ErrSpaceStorageMissing
return
}
objDb, err := pogreb.Open(dbPath, defPogrebOptions) objDb, err := pogreb.Open(dbPath, defPogrebOptions)
if err != nil { if err != nil {
return return