Update sync handler
This commit is contained in:
parent
ce2c2eaecc
commit
0e95dbfecf
@ -51,6 +51,9 @@ message ObjectSyncMessage {
|
|||||||
ObjectSyncContentValue content = 2;
|
ObjectSyncContentValue content = 2;
|
||||||
acl.TreeHeader treeHeader = 3;
|
acl.TreeHeader treeHeader = 3;
|
||||||
string treeId = 4;
|
string treeId = 4;
|
||||||
|
|
||||||
|
string identity = 5;
|
||||||
|
string peerSignature = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ObjectSyncContentValue provides different types for object sync
|
// ObjectSyncContentValue provides different types for object sync
|
||||||
@ -72,7 +75,8 @@ message ObjectHeadUpdate {
|
|||||||
// ObjectHeadUpdate is a message sent when document needs full sync
|
// ObjectHeadUpdate is a message sent when document needs full sync
|
||||||
message ObjectFullSyncRequest {
|
message ObjectFullSyncRequest {
|
||||||
repeated string heads = 1;
|
repeated string heads = 1;
|
||||||
repeated string snapshotPath = 2;
|
repeated acl.RawTreeChangeWithId changes = 2;
|
||||||
|
repeated string snapshotPath = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ObjectFullSyncResponse is a message sent as a response for a specific full sync
|
// ObjectFullSyncResponse is a message sent as a response for a specific full sync
|
||||||
|
|||||||
@ -320,10 +320,12 @@ func (m *HeadSyncResponse) GetResults() []*HeadSyncResult {
|
|||||||
|
|
||||||
// ObjectSyncMessage is a message sent on object sync
|
// ObjectSyncMessage is a message sent on object sync
|
||||||
type ObjectSyncMessage struct {
|
type ObjectSyncMessage struct {
|
||||||
SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"`
|
SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"`
|
||||||
Content *ObjectSyncContentValue `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"`
|
Content *ObjectSyncContentValue `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"`
|
||||||
TreeHeader *aclpb.TreeHeader `protobuf:"bytes,3,opt,name=treeHeader,proto3" json:"treeHeader,omitempty"`
|
TreeHeader *aclpb.TreeHeader `protobuf:"bytes,3,opt,name=treeHeader,proto3" json:"treeHeader,omitempty"`
|
||||||
TreeId string `protobuf:"bytes,4,opt,name=treeId,proto3" json:"treeId,omitempty"`
|
TreeId string `protobuf:"bytes,4,opt,name=treeId,proto3" json:"treeId,omitempty"`
|
||||||
|
Identity string `protobuf:"bytes,5,opt,name=identity,proto3" json:"identity,omitempty"`
|
||||||
|
PeerSignature string `protobuf:"bytes,6,opt,name=peerSignature,proto3" json:"peerSignature,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ObjectSyncMessage) Reset() { *m = ObjectSyncMessage{} }
|
func (m *ObjectSyncMessage) Reset() { *m = ObjectSyncMessage{} }
|
||||||
@ -387,6 +389,20 @@ func (m *ObjectSyncMessage) GetTreeId() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *ObjectSyncMessage) GetIdentity() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.Identity
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ObjectSyncMessage) GetPeerSignature() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.PeerSignature
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
// ObjectSyncContentValue provides different types for object sync
|
// ObjectSyncContentValue provides different types for object sync
|
||||||
type ObjectSyncContentValue struct {
|
type ObjectSyncContentValue struct {
|
||||||
// Types that are valid to be assigned to Value:
|
// Types that are valid to be assigned to Value:
|
||||||
@ -549,8 +565,9 @@ func (m *ObjectHeadUpdate) GetSnapshotPath() []string {
|
|||||||
|
|
||||||
// ObjectHeadUpdate is a message sent when document needs full sync
|
// ObjectHeadUpdate is a message sent when document needs full sync
|
||||||
type ObjectFullSyncRequest struct {
|
type ObjectFullSyncRequest struct {
|
||||||
Heads []string `protobuf:"bytes,1,rep,name=heads,proto3" json:"heads,omitempty"`
|
Heads []string `protobuf:"bytes,1,rep,name=heads,proto3" json:"heads,omitempty"`
|
||||||
SnapshotPath []string `protobuf:"bytes,2,rep,name=snapshotPath,proto3" json:"snapshotPath,omitempty"`
|
Changes []*aclpb.RawTreeChangeWithId `protobuf:"bytes,2,rep,name=changes,proto3" json:"changes,omitempty"`
|
||||||
|
SnapshotPath []string `protobuf:"bytes,3,rep,name=snapshotPath,proto3" json:"snapshotPath,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ObjectFullSyncRequest) Reset() { *m = ObjectFullSyncRequest{} }
|
func (m *ObjectFullSyncRequest) Reset() { *m = ObjectFullSyncRequest{} }
|
||||||
@ -593,6 +610,13 @@ func (m *ObjectFullSyncRequest) GetHeads() []string {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *ObjectFullSyncRequest) GetChanges() []*aclpb.RawTreeChangeWithId {
|
||||||
|
if m != nil {
|
||||||
|
return m.Changes
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (m *ObjectFullSyncRequest) GetSnapshotPath() []string {
|
func (m *ObjectFullSyncRequest) GetSnapshotPath() []string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.SnapshotPath
|
return m.SnapshotPath
|
||||||
@ -680,49 +704,51 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var fileDescriptor_5855f4ef9cf24cdb = []byte{
|
var fileDescriptor_5855f4ef9cf24cdb = []byte{
|
||||||
// 666 bytes of a gzipped FileDescriptorProto
|
// 695 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x54, 0x4f, 0x6f, 0xd3, 0x4e,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x55, 0xcb, 0x6f, 0xd3, 0x4e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c3, 0x66,
|
0x03, 0x1b, 0x13, 0xf2, 0xfb, 0x21, 0x4a, 0xc5, 0x4c, 0x28, 0x50, 0x89, 0x3b, 0x29, 0x37, 0x35,
|
||||||
0x21, 0x6f, 0x43, 0x31, 0x26, 0xf7, 0x52, 0xe9, 0x37, 0x72, 0xa4, 0x9b, 0x7d, 0x91, 0x96, 0x39,
|
0x59, 0x13, 0xf2, 0x11, 0x55, 0x2f, 0x91, 0x7e, 0x63, 0x81, 0x74, 0xbd, 0xcf, 0x13, 0x98, 0x75,
|
||||||
0x7b, 0x50, 0x9d, 0x92, 0x16, 0x85, 0x81, 0x42, 0xde, 0x81, 0x52, 0x4c, 0x32, 0x95, 0xcd, 0x88,
|
0x08, 0xe5, 0x29, 0x69, 0x61, 0xe0, 0x4b, 0x64, 0x2d, 0x28, 0x44, 0x24, 0x53, 0x9a, 0x06, 0x45,
|
||||||
0xc5, 0xbe, 0xca, 0x00, 0x91, 0x15, 0x3a, 0xdf, 0x18, 0xfc, 0xf7, 0xf4, 0xf0, 0x2d, 0xba, 0xda,
|
0x31, 0x2f, 0x2b, 0x00, 0x4f, 0x81, 0xd6, 0x2f, 0x03, 0xfe, 0x7b, 0x76, 0xfc, 0x16, 0x6d, 0xa5,
|
||||||
0xec, 0x3e, 0x46, 0xa5, 0xe4, 0x31, 0x5e, 0x23, 0xf4, 0x3e, 0x94, 0xdc, 0x30, 0xd0, 0x18, 0x68,
|
0x77, 0x9f, 0xa0, 0x94, 0xa2, 0x87, 0x57, 0x08, 0x7d, 0x00, 0x05, 0x3b, 0xf0, 0x15, 0xfa, 0x8a,
|
||||||
0x6a, 0xb6, 0xd2, 0x69, 0x4c, 0xce, 0x98, 0xf0, 0xec, 0x24, 0x25, 0x2f, 0xa5, 0x3f, 0x42, 0x91,
|
0x92, 0x2d, 0xb5, 0x6a, 0x93, 0x33, 0x26, 0x71, 0xf6, 0x63, 0xc8, 0x4b, 0xe1, 0x0d, 0x91, 0xa7,
|
||||||
0x01, 0x78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42, 0xbe, 0xab, 0x22, 0x14, 0x03, 0x76, 0x6b, 0xd1, 0xec, 0x26, 0xff, 0x01,
|
||||||
0x8b, 0xba, 0xf5, 0xfa, 0xf6, 0x5f, 0xff, 0xfa, 0x0f, 0x8b, 0xf4, 0xba, 0xfb, 0x3b, 0x00, 0x00,
|
0x95, 0xab, 0x36, 0xeb, 0xc6, 0x8e, 0xb1, 0xb7, 0xfb, 0xfd, 0xbc, 0x6a, 0x9c, 0x9d, 0x57, 0x8d,
|
||||||
0xff, 0xff, 0xcf, 0x4f, 0x53, 0x3d, 0x26, 0x06, 0x00, 0x00,
|
0x9f, 0xe7, 0x55, 0xe3, 0xeb, 0x45, 0x35, 0x73, 0x76, 0x51, 0xcd, 0xfc, 0xb8, 0xa8, 0x66, 0x5e,
|
||||||
|
0xdf, 0xfe, 0xe7, 0x17, 0xe7, 0x38, 0x4f, 0xaf, 0x7b, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x57,
|
||||||
|
0xb9, 0x93, 0x47, 0x9d, 0x06, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *HeadSyncRange) Marshal() (dAtA []byte, err error) {
|
func (m *HeadSyncRange) Marshal() (dAtA []byte, err error) {
|
||||||
@ -950,6 +976,20 @@ func (m *ObjectSyncMessage) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||||||
_ = i
|
_ = i
|
||||||
var l int
|
var l int
|
||||||
_ = l
|
_ = l
|
||||||
|
if len(m.PeerSignature) > 0 {
|
||||||
|
i -= len(m.PeerSignature)
|
||||||
|
copy(dAtA[i:], m.PeerSignature)
|
||||||
|
i = encodeVarintSpacesync(dAtA, i, uint64(len(m.PeerSignature)))
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x32
|
||||||
|
}
|
||||||
|
if len(m.Identity) > 0 {
|
||||||
|
i -= len(m.Identity)
|
||||||
|
copy(dAtA[i:], m.Identity)
|
||||||
|
i = encodeVarintSpacesync(dAtA, i, uint64(len(m.Identity)))
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x2a
|
||||||
|
}
|
||||||
if len(m.TreeId) > 0 {
|
if len(m.TreeId) > 0 {
|
||||||
i -= len(m.TreeId)
|
i -= len(m.TreeId)
|
||||||
copy(dAtA[i:], m.TreeId)
|
copy(dAtA[i:], m.TreeId)
|
||||||
@ -1167,6 +1207,20 @@ func (m *ObjectFullSyncRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||||||
copy(dAtA[i:], m.SnapshotPath[iNdEx])
|
copy(dAtA[i:], m.SnapshotPath[iNdEx])
|
||||||
i = encodeVarintSpacesync(dAtA, i, uint64(len(m.SnapshotPath[iNdEx])))
|
i = encodeVarintSpacesync(dAtA, i, uint64(len(m.SnapshotPath[iNdEx])))
|
||||||
i--
|
i--
|
||||||
|
dAtA[i] = 0x1a
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(m.Changes) > 0 {
|
||||||
|
for iNdEx := len(m.Changes) - 1; iNdEx >= 0; iNdEx-- {
|
||||||
|
{
|
||||||
|
size, err := m.Changes[iNdEx].MarshalToSizedBuffer(dAtA[:i])
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
i -= size
|
||||||
|
i = encodeVarintSpacesync(dAtA, i, uint64(size))
|
||||||
|
}
|
||||||
|
i--
|
||||||
dAtA[i] = 0x12
|
dAtA[i] = 0x12
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1361,6 +1415,14 @@ func (m *ObjectSyncMessage) Size() (n int) {
|
|||||||
if l > 0 {
|
if l > 0 {
|
||||||
n += 1 + l + sovSpacesync(uint64(l))
|
n += 1 + l + sovSpacesync(uint64(l))
|
||||||
}
|
}
|
||||||
|
l = len(m.Identity)
|
||||||
|
if l > 0 {
|
||||||
|
n += 1 + l + sovSpacesync(uint64(l))
|
||||||
|
}
|
||||||
|
l = len(m.PeerSignature)
|
||||||
|
if l > 0 {
|
||||||
|
n += 1 + l + sovSpacesync(uint64(l))
|
||||||
|
}
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1451,6 +1513,12 @@ func (m *ObjectFullSyncRequest) Size() (n int) {
|
|||||||
n += 1 + l + sovSpacesync(uint64(l))
|
n += 1 + l + sovSpacesync(uint64(l))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if len(m.Changes) > 0 {
|
||||||
|
for _, e := range m.Changes {
|
||||||
|
l = e.Size()
|
||||||
|
n += 1 + l + sovSpacesync(uint64(l))
|
||||||
|
}
|
||||||
|
}
|
||||||
if len(m.SnapshotPath) > 0 {
|
if len(m.SnapshotPath) > 0 {
|
||||||
for _, s := range m.SnapshotPath {
|
for _, s := range m.SnapshotPath {
|
||||||
l = len(s)
|
l = len(s)
|
||||||
@ -2216,6 +2284,70 @@ func (m *ObjectSyncMessage) Unmarshal(dAtA []byte) error {
|
|||||||
}
|
}
|
||||||
m.TreeId = string(dAtA[iNdEx:postIndex])
|
m.TreeId = string(dAtA[iNdEx:postIndex])
|
||||||
iNdEx = postIndex
|
iNdEx = postIndex
|
||||||
|
case 5:
|
||||||
|
if wireType != 2 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType)
|
||||||
|
}
|
||||||
|
var stringLen uint64
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowSpacesync
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
stringLen |= uint64(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
intStringLen := int(stringLen)
|
||||||
|
if intStringLen < 0 {
|
||||||
|
return ErrInvalidLengthSpacesync
|
||||||
|
}
|
||||||
|
postIndex := iNdEx + intStringLen
|
||||||
|
if postIndex < 0 {
|
||||||
|
return ErrInvalidLengthSpacesync
|
||||||
|
}
|
||||||
|
if postIndex > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
m.Identity = string(dAtA[iNdEx:postIndex])
|
||||||
|
iNdEx = postIndex
|
||||||
|
case 6:
|
||||||
|
if wireType != 2 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field PeerSignature", wireType)
|
||||||
|
}
|
||||||
|
var stringLen uint64
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowSpacesync
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
stringLen |= uint64(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
intStringLen := int(stringLen)
|
||||||
|
if intStringLen < 0 {
|
||||||
|
return ErrInvalidLengthSpacesync
|
||||||
|
}
|
||||||
|
postIndex := iNdEx + intStringLen
|
||||||
|
if postIndex < 0 {
|
||||||
|
return ErrInvalidLengthSpacesync
|
||||||
|
}
|
||||||
|
if postIndex > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
m.PeerSignature = string(dAtA[iNdEx:postIndex])
|
||||||
|
iNdEx = postIndex
|
||||||
default:
|
default:
|
||||||
iNdEx = preIndex
|
iNdEx = preIndex
|
||||||
skippy, err := skipSpacesync(dAtA[iNdEx:])
|
skippy, err := skipSpacesync(dAtA[iNdEx:])
|
||||||
@ -2602,6 +2734,40 @@ func (m *ObjectFullSyncRequest) Unmarshal(dAtA []byte) error {
|
|||||||
m.Heads = append(m.Heads, string(dAtA[iNdEx:postIndex]))
|
m.Heads = append(m.Heads, string(dAtA[iNdEx:postIndex]))
|
||||||
iNdEx = postIndex
|
iNdEx = postIndex
|
||||||
case 2:
|
case 2:
|
||||||
|
if wireType != 2 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field Changes", wireType)
|
||||||
|
}
|
||||||
|
var msglen int
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowSpacesync
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
msglen |= int(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if msglen < 0 {
|
||||||
|
return ErrInvalidLengthSpacesync
|
||||||
|
}
|
||||||
|
postIndex := iNdEx + msglen
|
||||||
|
if postIndex < 0 {
|
||||||
|
return ErrInvalidLengthSpacesync
|
||||||
|
}
|
||||||
|
if postIndex > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
m.Changes = append(m.Changes, &aclpb.RawTreeChangeWithId{})
|
||||||
|
if err := m.Changes[len(m.Changes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
iNdEx = postIndex
|
||||||
|
case 3:
|
||||||
if wireType != 2 {
|
if wireType != 2 {
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field SnapshotPath", wireType)
|
return fmt.Errorf("proto: wrong wireType = %d for field SnapshotPath", wireType)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,6 @@ import (
|
|||||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache"
|
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache"
|
||||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto"
|
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto"
|
||||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb"
|
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb"
|
||||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage"
|
|
||||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree"
|
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree"
|
||||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice"
|
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice"
|
||||||
)
|
)
|
||||||
@ -49,8 +48,6 @@ func (s *syncHandler) HandleHeadUpdate(
|
|||||||
var (
|
var (
|
||||||
fullRequest *spacesyncproto.ObjectFullSyncRequest
|
fullRequest *spacesyncproto.ObjectFullSyncRequest
|
||||||
result tree.AddResult
|
result tree.AddResult
|
||||||
// in case update changes are empty then we want to sync the whole tree
|
|
||||||
sendChangesOnFullSync = len(update.Changes) == 0
|
|
||||||
)
|
)
|
||||||
|
|
||||||
res, err := s.treeCache.GetTree(ctx, treeId)
|
res, err := s.treeCache.GetTree(ctx, treeId)
|
||||||
@ -74,9 +71,8 @@ func (s *syncHandler) HandleHeadUpdate(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if we couldn't add all the changes
|
// if we couldn't add all the changes
|
||||||
shouldFullSync := len(update.Changes) != len(result.Added)
|
if len(update.Changes) != len(result.Added) {
|
||||||
if shouldFullSync {
|
fullRequest, err = s.prepareFullSyncRequest(objTree, update)
|
||||||
fullRequest, err = s.prepareFullSyncRequest(objTree, sendChangesOnFullSync)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -84,11 +80,6 @@ func (s *syncHandler) HandleHeadUpdate(
|
|||||||
return nil
|
return nil
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// if there are no such tree
|
|
||||||
if err == storage.ErrUnknownTreeId {
|
|
||||||
fullRequest = &spacesyncproto.ObjectFullSyncRequest{}
|
|
||||||
}
|
|
||||||
// if we have incompatible heads, or we haven't seen the tree at all
|
|
||||||
if fullRequest != nil {
|
if fullRequest != nil {
|
||||||
return s.syncClient.SendAsync(senderId, spacesyncproto.WrapFullRequest(fullRequest, header, treeId))
|
return s.syncClient.SendAsync(senderId, spacesyncproto.WrapFullRequest(fullRequest, header, treeId))
|
||||||
}
|
}
|
||||||
@ -109,21 +100,23 @@ func (s *syncHandler) HandleFullSyncRequest(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: check if sync request contains changes and add them (also do head update in this case)
|
|
||||||
err = func() error {
|
err = func() error {
|
||||||
objTree := res.TreeContainer.Tree()
|
objTree := res.TreeContainer.Tree()
|
||||||
objTree.Lock()
|
objTree.Lock()
|
||||||
defer res.Release()
|
defer res.Release()
|
||||||
defer objTree.Unlock()
|
defer objTree.Unlock()
|
||||||
fullResponse, err = s.prepareFullSyncResponse(treeId, request.SnapshotPath, request.Heads, objTree)
|
|
||||||
|
_, err = objTree.AddRawChanges(ctx, request.Changes...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
|
fullResponse, err = s.prepareFullSyncResponse(treeId, request.SnapshotPath, request.Heads, objTree)
|
||||||
|
return err
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return
|
||||||
}
|
}
|
||||||
return s.syncClient.SendAsync(senderId, spacesyncproto.WrapFullResponse(fullResponse, header, treeId))
|
return s.syncClient.SendAsync(senderId, spacesyncproto.WrapFullResponse(fullResponse, header, treeId))
|
||||||
}
|
}
|
||||||
@ -135,8 +128,6 @@ func (s *syncHandler) HandleFullSyncResponse(
|
|||||||
header *aclpb.TreeHeader,
|
header *aclpb.TreeHeader,
|
||||||
treeId string) (err error) {
|
treeId string) (err error) {
|
||||||
|
|
||||||
var result tree.AddResult
|
|
||||||
|
|
||||||
res, err := s.treeCache.GetTree(ctx, treeId)
|
res, err := s.treeCache.GetTree(ctx, treeId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -153,27 +144,28 @@ func (s *syncHandler) HandleFullSyncResponse(
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err = objTree.AddRawChanges(ctx, response.Changes...)
|
_, err = objTree.AddRawChanges(ctx, response.Changes...)
|
||||||
|
return err
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// if error or nothing has changed
|
|
||||||
if (err != nil || len(result.Added) == 0) && err != storage.ErrUnknownTreeId {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
// if we have a new tree
|
|
||||||
if err == storage.ErrUnknownTreeId {
|
|
||||||
return s.addTree(ctx, response, header, treeId)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *syncHandler) prepareFullSyncRequest(t tree.ObjectTree, sendOwnChanges bool) (*spacesyncproto.ObjectFullSyncRequest, error) {
|
func (s *syncHandler) prepareFullSyncRequest(
|
||||||
// TODO: add send own changes logic
|
t tree.ObjectTree,
|
||||||
|
update *spacesyncproto.ObjectHeadUpdate) (req *spacesyncproto.ObjectFullSyncRequest, err error) {
|
||||||
|
req = &spacesyncproto.ObjectFullSyncRequest{
|
||||||
|
Heads: t.Heads(),
|
||||||
|
SnapshotPath: t.SnapshotPath(),
|
||||||
|
}
|
||||||
|
if len(update.Changes) != 0 {
|
||||||
|
var changesAfterSnapshot []*aclpb.RawTreeChangeWithId
|
||||||
|
changesAfterSnapshot, err = t.ChangesAfterCommonSnapshot(update.SnapshotPath, update.Heads)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
req.Changes = changesAfterSnapshot
|
||||||
|
}
|
||||||
return &spacesyncproto.ObjectFullSyncRequest{
|
return &spacesyncproto.ObjectFullSyncRequest{
|
||||||
Heads: t.Heads(),
|
Heads: t.Heads(),
|
||||||
SnapshotPath: t.SnapshotPath(),
|
SnapshotPath: t.SnapshotPath(),
|
||||||
@ -182,7 +174,8 @@ func (s *syncHandler) prepareFullSyncRequest(t tree.ObjectTree, sendOwnChanges b
|
|||||||
|
|
||||||
func (s *syncHandler) prepareFullSyncResponse(
|
func (s *syncHandler) prepareFullSyncResponse(
|
||||||
treeId string,
|
treeId string,
|
||||||
theirPath, theirHeads []string,
|
theirPath,
|
||||||
|
theirHeads []string,
|
||||||
t tree.ObjectTree) (*spacesyncproto.ObjectFullSyncResponse, error) {
|
t tree.ObjectTree) (*spacesyncproto.ObjectFullSyncResponse, error) {
|
||||||
ourChanges, err := t.ChangesAfterCommonSnapshot(theirPath, theirHeads)
|
ourChanges, err := t.ChangesAfterCommonSnapshot(theirPath, theirHeads)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -195,19 +188,3 @@ func (s *syncHandler) prepareFullSyncResponse(
|
|||||||
SnapshotPath: t.SnapshotPath(),
|
SnapshotPath: t.SnapshotPath(),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *syncHandler) addTree(
|
|
||||||
ctx context.Context,
|
|
||||||
response *spacesyncproto.ObjectFullSyncResponse,
|
|
||||||
header *aclpb.TreeHeader,
|
|
||||||
treeId string) error {
|
|
||||||
|
|
||||||
return s.treeCache.AddTree(
|
|
||||||
ctx,
|
|
||||||
storage.TreeStorageCreatePayload{
|
|
||||||
TreeId: treeId,
|
|
||||||
Header: header,
|
|
||||||
Changes: response.Changes,
|
|
||||||
Heads: response.Heads,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user