1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-09 09:35:00 +09:00

GO-2875 Fix tree syncer

This commit is contained in:
mcrakhman 2024-02-15 17:33:56 +01:00
parent 8dee9a675c
commit d9cf5c3a9e
No known key found for this signature in database
GPG key ID: DED12CFEF5B8396B
4 changed files with 14 additions and 5 deletions

View file

@ -64,6 +64,7 @@ type treeSyncer struct {
headPools map[string]*executor
treeManager treemanager.TreeManager
isRunning bool
isSyncing bool
}
func NewTreeSyncer(spaceId string) treesyncer.TreeSyncer {
@ -80,6 +81,7 @@ func NewTreeSyncer(spaceId string) treesyncer.TreeSyncer {
}
func (t *treeSyncer) Init(a *app.App) (err error) {
t.isSyncing = true
t.treeManager = app.MustComponent[treemanager.TreeManager](a)
return nil
}
@ -123,12 +125,13 @@ func (t *treeSyncer) StopSync() {
t.Lock()
defer t.Unlock()
t.isRunning = false
t.isSyncing = false
}
func (t *treeSyncer) ShouldSync(peerId string) bool {
t.Lock()
defer t.Unlock()
return t.isRunning
return t.isSyncing
}
func (t *treeSyncer) SyncAll(ctx context.Context, peerId string, existing, missing []string) error {

View file

@ -6,7 +6,9 @@ import (
"strings"
"sync"
"github.com/anyproto/any-sync/commonspace/object/acl/list"
"github.com/anyproto/any-sync/commonspace/object/tree/objecttree"
"github.com/anyproto/any-sync/commonspace/object/tree/treestorage"
"github.com/gogo/protobuf/types"
"github.com/anyproto/any-sync/accountservice"
@ -101,9 +103,11 @@ type BuildOptions struct {
func (b *BuildOptions) BuildTreeOpts() objecttreebuilder.BuildTreeOpts {
return objecttreebuilder.BuildTreeOpts{
Listener: b.Listener,
TreeBuilder: objecttree.BuildKeyVerifiableObjectTree,
TreeValidator: objecttree.ValidateFilterReadKeyRawTreeBuildFunc,
Listener: b.Listener,
TreeBuilder: objecttree.BuildKeyFilterableObjectTree,
TreeValidator: func(payload treestorage.TreeStorageCreatePayload, buildFunc objecttree.BuildObjectTreeFunc, aclList list.AclList) (retPayload treestorage.TreeStorageCreatePayload, err error) {
return objecttree.ValidateFilterRawTree(payload, aclList)
},
}
}

2
go.mod
View file

@ -7,7 +7,7 @@ require (
github.com/PuerkitoBio/goquery v1.8.1
github.com/VividCortex/ewma v1.2.0
github.com/adrium/goheif v0.0.0-20230113233934-ca402e77a786
github.com/anyproto/any-sync v0.3.21-0.20240214211744-c16812df55b0
github.com/anyproto/any-sync v0.3.21-0.20240215134719-58f333354e88
github.com/anyproto/go-naturaldate/v2 v2.0.2-0.20230524105841-9829cfd13438
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de
github.com/blevesearch/bleve/v2 v2.3.10

2
go.sum
View file

@ -123,6 +123,8 @@ github.com/anyproto/any-sync v0.3.21-0.20240214205531-bbafd52502ca h1:qr/WjmFC3+
github.com/anyproto/any-sync v0.3.21-0.20240214205531-bbafd52502ca/go.mod h1:exw/7+W3jfkuaVWsStQD8s8aLFT9L2NBiW/DVwTNi/E=
github.com/anyproto/any-sync v0.3.21-0.20240214211744-c16812df55b0 h1:g7RqB1EyX8H4hT/ykD+yFuzVVDchKtwBn3p3G5F820E=
github.com/anyproto/any-sync v0.3.21-0.20240214211744-c16812df55b0/go.mod h1:exw/7+W3jfkuaVWsStQD8s8aLFT9L2NBiW/DVwTNi/E=
github.com/anyproto/any-sync v0.3.21-0.20240215134719-58f333354e88 h1:PDT6l11gQhupAHwGSECbzPNHZ+rCwDLpKh66KMk5GXU=
github.com/anyproto/any-sync v0.3.21-0.20240215134719-58f333354e88/go.mod h1:ViWsWYe+jDuYip9gdp89RqvTfgHzorGypZSn+Ae0WUU=
github.com/anyproto/badger/v4 v4.2.1-0.20240110160636-80743fa3d580 h1:Ba80IlCCxkZ9H1GF+7vFu/TSpPvbpDCxXJ5ogc4euYc=
github.com/anyproto/badger/v4 v4.2.1-0.20240110160636-80743fa3d580/go.mod h1:T/uWAYxrXdaXw64ihI++9RMbKTCpKd/yE9+saARew7k=
github.com/anyproto/go-chash v0.1.0 h1:I9meTPjXFRfXZHRJzjOHC/XF7Q5vzysKkiT/grsogXY=