More fixes to synctree and objecttree
This commit is contained in:
parent
fd7c0010d8
commit
2fa94cfe7b
@ -129,9 +129,7 @@ func (d *diffSyncer) pingTreesInCache(ctx context.Context, trees []string) {
|
|||||||
// it may be already there (i.e. loaded)
|
// it may be already there (i.e. loaded)
|
||||||
// and build func will not be called, thus we won't sync the tree
|
// and build func will not be called, thus we won't sync the tree
|
||||||
// therefore we just do it manually
|
// therefore we just do it manually
|
||||||
syncTree.Lock()
|
|
||||||
syncTree.Ping()
|
syncTree.Ping()
|
||||||
syncTree.Unlock()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -313,7 +313,9 @@ func (s *syncTree) checkAlive() (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *syncTree) Ping() (err error) {
|
func (s *syncTree) Ping() (err error) {
|
||||||
|
s.Lock()
|
||||||
headUpdate := s.syncClient.CreateHeadUpdate(s, nil)
|
headUpdate := s.syncClient.CreateHeadUpdate(s, nil)
|
||||||
|
s.Unlock()
|
||||||
return s.syncClient.BroadcastAsyncOrSendResponsible(headUpdate)
|
return s.syncClient.BroadcastAsyncOrSendResponsible(headUpdate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -42,7 +42,7 @@ func (s *syncTreeHandler) HandleMessage(ctx context.Context, senderId string, ms
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
s.handlerLock.Lock()
|
s.handlerLock.Lock()
|
||||||
queue := s.handlerMap[senderId]
|
queue := s.handlerMap[senderId]
|
||||||
queueFull := len(queue) >= maxQueueSize
|
queueFull := len(queue) >= maxQueueSize
|
||||||
|
|||||||
@ -246,7 +246,7 @@ func (st *ACLState) applyChangeData(changeData *aclrecordproto.ACLData, hash uin
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !st.hasPermission(identity, aclrecordproto.ACLUserPermissions_Admin) {
|
if !st.HasPermission(identity, aclrecordproto.ACLUserPermissions_Admin) {
|
||||||
err = fmt.Errorf("user %s must have admin permissions", identity)
|
err = fmt.Errorf("user %s must have admin permissions", identity)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -413,7 +413,7 @@ func (st *ACLState) decryptReadKeyAndHash(msg []byte) (*symmetric.Key, uint64, e
|
|||||||
return key, hasher.Sum64(), nil
|
return key, hasher.Sum64(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (st *ACLState) hasPermission(identity []byte, permission aclrecordproto.ACLUserPermissions) bool {
|
func (st *ACLState) HasPermission(identity []byte, permission aclrecordproto.ACLUserPermissions) bool {
|
||||||
state, exists := st.userStates[string(identity)]
|
state, exists := st.userStates[string(identity)]
|
||||||
if !exists {
|
if !exists {
|
||||||
return false
|
return false
|
||||||
|
|||||||
@ -4,6 +4,7 @@ package tree
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/aclrecordproto"
|
||||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/common"
|
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/common"
|
||||||
list "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/list"
|
list "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/list"
|
||||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage"
|
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage"
|
||||||
@ -197,6 +198,13 @@ func (ot *objectTree) prepareBuilderContent(content SignableChangeContent) (cnt
|
|||||||
readKey *symmetric.Key
|
readKey *symmetric.Key
|
||||||
readKeyHash uint64
|
readKeyHash uint64
|
||||||
)
|
)
|
||||||
|
canWrite := state.HasPermission(content.Identity, aclrecordproto.ACLUserPermissions_Writer) ||
|
||||||
|
state.HasPermission(content.Identity, aclrecordproto.ACLUserPermissions_Admin)
|
||||||
|
if !canWrite {
|
||||||
|
err = list.ErrInsufficientPermissions
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if content.IsEncrypted {
|
if content.IsEncrypted {
|
||||||
readKeyHash = state.CurrentReadKeyHash()
|
readKeyHash = state.CurrentReadKeyHash()
|
||||||
readKey, err = state.CurrentReadKey()
|
readKey, err = state.CurrentReadKey()
|
||||||
|
|||||||
@ -58,7 +58,7 @@ func (s *service) registerScripts() {
|
|||||||
}
|
}
|
||||||
for _, p := range addresses {
|
for _, p := range addresses {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
createMany(p)
|
go createMany(p)
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
if mError.Err() != nil {
|
if mError.Err() != nil {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user