Make stuff compile
This commit is contained in:
parent
2ea1ddddb8
commit
89715bdca7
@ -103,7 +103,7 @@ func (s *service) UpdateDocumentTree(ctx context.Context, id, text string) (err
|
|||||||
Identity: s.account.Account().Identity,
|
Identity: s.account.Account().Identity,
|
||||||
IsSnapshot: false,
|
IsSnapshot: false,
|
||||||
}
|
}
|
||||||
ch, err = docTree.AddContent(ctx, aclTree, signable)
|
ch, err = docTree.AddContent(ctx, signable)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -268,9 +268,11 @@ func (r *requestHandler) createTree(
|
|||||||
return r.treeCache.Add(
|
return r.treeCache.Add(
|
||||||
ctx,
|
ctx,
|
||||||
treeId,
|
treeId,
|
||||||
treecache.TreePayload{
|
storage.TreeStorageCreatePayload{
|
||||||
|
TreeId: treeId,
|
||||||
Header: header,
|
Header: header,
|
||||||
Changes: response.Changes,
|
Changes: response.Changes,
|
||||||
|
Heads: response.Heads,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,7 +285,8 @@ func (r *requestHandler) createACLList(
|
|||||||
return r.treeCache.Add(
|
return r.treeCache.Add(
|
||||||
ctx,
|
ctx,
|
||||||
treeId,
|
treeId,
|
||||||
treecache.ACLListPayload{
|
storage.ACLListStorageCreatePayload{
|
||||||
|
ListId: treeId,
|
||||||
Header: header,
|
Header: header,
|
||||||
Records: req.Records,
|
Records: req.Records,
|
||||||
})
|
})
|
||||||
|
|||||||
@ -21,19 +21,9 @@ type ObjFunc = func(obj interface{}) error
|
|||||||
|
|
||||||
var log = logger.NewNamed("treecache")
|
var log = logger.NewNamed("treecache")
|
||||||
|
|
||||||
type TreePayload struct {
|
|
||||||
Header *aclpb.Header
|
|
||||||
Changes []*aclpb.RawChange
|
|
||||||
}
|
|
||||||
|
|
||||||
type ACLListPayload struct {
|
|
||||||
Header *aclpb.Header
|
|
||||||
Records []*aclpb.RawRecord
|
|
||||||
}
|
|
||||||
|
|
||||||
type Service interface {
|
type Service interface {
|
||||||
Do(ctx context.Context, id string, f ObjFunc) error
|
Do(ctx context.Context, id string, f ObjFunc) error
|
||||||
Add(ctx context.Context, id string, payload interface{}) error
|
Add(ctx context.Context, id string, payload any) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type service struct {
|
type service struct {
|
||||||
@ -59,23 +49,23 @@ func (s *service) Do(ctx context.Context, treeId string, f ObjFunc) error {
|
|||||||
return f(t)
|
return f(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *service) Add(ctx context.Context, treeId string, payload interface{}) error {
|
func (s *service) Add(ctx context.Context, treeId string, payload any) error {
|
||||||
switch pl := payload.(type) {
|
switch pl := payload.(type) {
|
||||||
case TreePayload:
|
case aclstorage.TreeStorageCreatePayload:
|
||||||
log.
|
log.
|
||||||
With(zap.String("treeId", treeId), zap.Int("len(changes)", len(pl.Changes))).
|
With(zap.String("treeId", treeId), zap.Int("len(changes)", len(pl.Changes))).
|
||||||
Debug("adding Tree with changes")
|
Debug("adding Tree with changes")
|
||||||
|
|
||||||
_, err := s.storage.CreateTreeStorage(treeId, pl.Header, pl.Changes)
|
_, err := s.storage.CreateTreeStorage(payload.(aclstorage.TreeStorageCreatePayload))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
case ACLListPayload:
|
case aclstorage.ACLListStorageCreatePayload:
|
||||||
log.
|
log.
|
||||||
With(zap.String("treeId", treeId), zap.Int("len(changes)", len(pl.Records))).
|
With(zap.String("treeId", treeId), zap.Int("len(changes)", len(pl.Records))).
|
||||||
Debug("adding ACLList with records")
|
Debug("adding ACLList with records")
|
||||||
|
|
||||||
_, err := s.storage.CreateACLListStorage(treeId, pl.Header, pl.Records)
|
_, err := s.storage.CreateACLListStorage(payload.(aclstorage.ACLListStorageCreatePayload))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -123,19 +113,15 @@ func (s *service) loadTree(ctx context.Context, id string) (ocache.Object, error
|
|||||||
return nil, fmt.Errorf("incorrect type")
|
return nil, fmt.Errorf("incorrect type")
|
||||||
}
|
}
|
||||||
log.Info("got header", zap.String("header", header.String()))
|
log.Info("got header", zap.String("header", header.String()))
|
||||||
var docTree tree.ObjectTree
|
var objTree tree.ObjectTree
|
||||||
// TODO: it is a question if we need to use ACLList on the first tree build, because we can think that the tree is already validated
|
|
||||||
err = s.Do(ctx, header.AclListId, func(obj interface{}) error {
|
err = s.Do(ctx, header.AclListId, func(obj interface{}) error {
|
||||||
aclTree := obj.(list.ACLList)
|
aclList := obj.(list.ACLList)
|
||||||
aclTree.RLock()
|
objTree, err = tree.BuildObjectTree(t.(aclstorage.TreeStorage), nil, aclList)
|
||||||
defer aclTree.RUnlock()
|
|
||||||
|
|
||||||
docTree, err = tree.BuildDocTreeWithIdentity(t.(aclstorage.TreeStorage), s.account.Account(), nil, aclTree)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
return docTree, err
|
return objTree, err
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user