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

Update any-sync to include changes related to get tree errors

This commit is contained in:
mcrakhman 2023-04-25 18:17:59 +02:00 committed by Mikhail Iudin
parent 56feb91ced
commit 98899f106e
No known key found for this signature in database
GPG key ID: FAAAA8BAABDFF1C0
10 changed files with 112 additions and 611 deletions

View file

@ -23,7 +23,7 @@ import (
"github.com/libp2p/go-libp2p/core/peer"
"github.com/anytypeio/any-sync/app"
"github.com/anytypeio/any-sync/commonspace/object/treegetter"
"github.com/anytypeio/any-sync/commonspace/object/treemanager"
"github.com/anytypeio/any-sync/commonspace/spacesyncproto"
cp "github.com/otiai10/copy"
@ -382,7 +382,7 @@ func (mw *Middleware) AccountSelect(cctx context.Context, req *pb.RpcAccountSele
// we already have this account running, lets just stop events
if mw.app != nil && req.Id == mw.app.MustComponent(walletComp.CName).(walletComp.Wallet).GetAccountPrivkey().GetPublic().Account() {
mw.app.MustComponent(treegetter.CName).(*block.Service).CloseBlocks()
mw.app.MustComponent(treemanager.CName).(*block.Service).CloseBlocks()
acc := &model.Account{Id: req.Id}
acc.Info = mw.getInfo()
return response(acc, pb.RpcAccountSelectResponseError_NULL, nil)

View file

@ -13,7 +13,7 @@ import (
"time"
"github.com/anytypeio/any-sync/app"
"github.com/anytypeio/any-sync/commonspace/object/treegetter"
"github.com/anytypeio/any-sync/commonspace/object/treemanager"
"github.com/gogo/protobuf/types"
"github.com/anytypeio/go-anytype-middleware/core/block/editor/state"
@ -70,7 +70,7 @@ func New(tempDirService *core.TempDirService) Service {
}
func (s *service) Init(a *app.App) (err error) {
s.detailsSetter = a.MustComponent(treegetter.CName).(DetailsSetter)
s.detailsSetter = a.MustComponent(treemanager.CName).(DetailsSetter)
s.creator = a.MustComponent("objectCreator").(ObjectCreator)
s.store = a.MustComponent(objectstore.CName).(objectstore.ObjectStore)
s.linkPreview = a.MustComponent(linkpreview.CName).(linkpreview.LinkPreview)

View file

@ -6,7 +6,7 @@ import (
"time"
"github.com/anytypeio/any-sync/app"
"github.com/anytypeio/any-sync/commonspace/object/treegetter"
"github.com/anytypeio/any-sync/commonspace/object/treemanager"
"github.com/globalsign/mgo/bson"
"github.com/gogo/protobuf/types"
@ -100,7 +100,7 @@ func (p *Workspaces) Init(ctx *smartblock.InitContext) (err error) {
p.app = ctx.App
// TODO pass as explicit deps
p.sourceService = p.app.MustComponent(source.CName).(source.Service)
p.templateCloner = p.app.MustComponent(treegetter.CName).(templateCloner)
p.templateCloner = p.app.MustComponent(treemanager.CName).(templateCloner)
p.AddHook(p.updateSubObject, smartblock.HookAfterApply)

View file

@ -11,7 +11,7 @@ import (
"github.com/anytypeio/any-sync/app"
"github.com/anytypeio/any-sync/app/ocache"
"github.com/anytypeio/any-sync/commonspace/object/tree/treestorage"
"github.com/anytypeio/any-sync/commonspace/object/treegetter"
"github.com/anytypeio/any-sync/commonspace/object/treemanager"
"github.com/gogo/protobuf/types"
"github.com/hashicorp/go-multierror"
"github.com/ipfs/go-datastore/query"
@ -63,7 +63,7 @@ import (
)
const (
CName = treegetter.CName
CName = treemanager.CName
linkObjectShare = "anytype://object/share?"
)

View file

@ -6,7 +6,7 @@ import (
"strings"
"github.com/anytypeio/any-sync/app"
"github.com/anytypeio/any-sync/commonspace/object/treegetter"
"github.com/anytypeio/any-sync/commonspace/object/treemanager"
"github.com/gogo/protobuf/types"
"github.com/ipfs/go-datastore/query"
@ -23,7 +23,7 @@ import (
const CName = "relation"
const blockServiceCName = treegetter.CName
const blockServiceCName = treemanager.CName
var (
ErrNotFound = errors.New("relation not found")

40
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/anytypeio/any-sync v0.0.34
github.com/anytypeio/any-sync v0.0.35
github.com/anytypeio/go-naturaldate/v2 v2.0.1
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de
github.com/blevesearch/bleve/v2 v2.3.6
@ -56,7 +56,7 @@ require (
github.com/joho/godotenv v1.5.1
github.com/jsummers/gobmp v0.0.0-20151104160322-e2ba15ffa76e
github.com/kelseyhightower/envconfig v1.4.0
github.com/libp2p/go-libp2p v0.26.3
github.com/libp2p/go-libp2p v0.27.1
github.com/libp2p/zeroconf/v2 v2.2.0
github.com/logrusorgru/aurora v2.0.3+incompatible
github.com/magiconair/properties v1.8.4
@ -65,7 +65,7 @@ require (
github.com/miolini/datacounter v1.0.2
github.com/mr-tron/base58 v1.2.0
github.com/multiformats/go-base32 v0.1.0
github.com/multiformats/go-multiaddr v0.8.0
github.com/multiformats/go-multiaddr v0.9.0
github.com/multiformats/go-multiaddr-dns v0.3.1
github.com/multiformats/go-multibase v0.2.0
github.com/multiformats/go-multihash v0.2.1
@ -85,9 +85,9 @@ require (
github.com/textileio/go-threads v0.0.0-00010101000000-000000000000
github.com/uber/jaeger-client-go v2.28.0+incompatible
github.com/yuin/goldmark v1.5.4
go.uber.org/multierr v1.9.0
go.uber.org/multierr v1.11.0
go.uber.org/zap v1.24.0
golang.org/x/exp v0.0.0-20230321023759-10a507213a29
golang.org/x/exp v0.0.0-20230420155640-133eef4313cb
golang.org/x/image v0.6.0
golang.org/x/net v0.9.0
golang.org/x/oauth2 v0.5.0
@ -129,7 +129,7 @@ require (
github.com/andybalholm/cascadia v1.3.1 // indirect
github.com/anytypeio/go-chash v0.1.0 // indirect
github.com/aokoli/goutils v1.0.1 // indirect
github.com/benbjohnson/clock v1.3.0 // indirect
github.com/benbjohnson/clock v1.3.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.2.0 // indirect
github.com/blevesearch/bleve_index_api v1.0.5 // indirect
@ -151,7 +151,7 @@ require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/crackcomm/go-gitignore v0.0.0-20170627025303-887ab5e44cc3 // indirect
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
github.com/dgraph-io/badger v1.6.2 // indirect
github.com/dgraph-io/ristretto v0.1.1 // indirect
@ -166,7 +166,7 @@ require (
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-shiori/dom v0.0.0-20210627111528-4e4722cd0d65 // indirect
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/go-xmlfmt/xmlfmt v0.0.0-20191208150333-d5b6f63a941b // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/gogo/googleapis v1.3.1 // indirect
@ -178,7 +178,7 @@ require (
github.com/golang/snappy v0.0.4 // indirect
github.com/google/flatbuffers v1.12.1 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/pprof v0.0.0-20221203041831-ce31453925ec // indirect
github.com/google/pprof v0.0.0-20230406165453-00490a63f317 // indirect
github.com/gosimple/unidecode v1.0.1 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
@ -202,23 +202,23 @@ require (
github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect
github.com/jbenet/goprocess v0.1.4 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.15.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.3 // indirect
github.com/klauspost/compress v1.16.5 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/libp2p/go-flow-metrics v0.1.0 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-isatty v0.0.18 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/miekg/dns v1.1.50 // indirect
github.com/miekg/dns v1.1.53 // indirect
github.com/minio/sha256-simd v1.0.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mschoch/smat v0.2.0 // indirect
github.com/multiformats/go-base36 v0.2.0 // indirect
github.com/multiformats/go-multicodec v0.8.0 // indirect
github.com/multiformats/go-multicodec v0.8.1 // indirect
github.com/multiformats/go-multistream v0.4.1 // indirect
github.com/multiformats/go-varint v0.0.7 // indirect
github.com/mwitkow/go-proto-validators v0.0.0-20180403085117-0950a7990007 // indirect
github.com/onsi/ginkgo/v2 v2.5.1 // indirect
github.com/onsi/ginkgo/v2 v2.9.2 // indirect
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/polydawn/refmt v0.89.0 // indirect
@ -226,9 +226,9 @@ require (
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/pseudomuto/protokit v0.2.0 // indirect; indirectirect
github.com/quic-go/qtls-go1-19 v0.2.1 // indirect
github.com/quic-go/qtls-go1-20 v0.1.1 // indirect
github.com/quic-go/quic-go v0.33.0 // indirect
github.com/quic-go/qtls-go1-19 v0.3.2 // indirect
github.com/quic-go/qtls-go1-20 v0.2.2 // indirect
github.com/quic-go/quic-go v0.34.0 // indirect
github.com/rs/cors v1.7.0 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
@ -245,10 +245,10 @@ require (
go.opentelemetry.io/otel/trace v1.11.2 // indirect
go.uber.org/atomic v1.10.0 // indirect
golang.org/x/crypto v0.8.0 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/tools v0.6.0 // indirect
golang.org/x/tools v0.8.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220114231437-d2e6a121cae0 // indirect

626
go.sum

File diff suppressed because it is too large Load diff

View file

@ -9,16 +9,15 @@ import (
"github.com/anytypeio/any-sync/app"
"github.com/anytypeio/any-sync/commonfile/fileservice"
"github.com/anytypeio/any-sync/commonspace/object/tree/treestorage"
"github.com/anytypeio/any-sync/commonspace/object/treegetter"
"github.com/anytypeio/any-sync/commonspace/object/treemanager"
"github.com/libp2p/go-libp2p/core/peer"
"go.uber.org/zap"
"github.com/anytypeio/go-anytype-middleware/core/anytype/config"
files2 "github.com/anytypeio/go-anytype-middleware/core/files"
"github.com/anytypeio/go-anytype-middleware/core/filestorage"
"github.com/anytypeio/go-anytype-middleware/core/wallet"
"github.com/anytypeio/go-anytype-middleware/metrics"
coresb "github.com/anytypeio/go-anytype-middleware/pkg/lib/core/smartblock"
"github.com/anytypeio/go-anytype-middleware/pkg/lib/files"
"github.com/anytypeio/go-anytype-middleware/pkg/lib/localstore/addr"
"github.com/anytypeio/go-anytype-middleware/pkg/lib/localstore/filestore"
"github.com/anytypeio/go-anytype-middleware/pkg/lib/localstore/objectstore"
@ -41,13 +40,16 @@ type Service interface {
EnsurePredefinedBlocks(ctx context.Context) error
PredefinedBlocks() threads.DerivedSmartblockIds
// FileOffload removes file blocks recursively, but leave details
FileOffload(id string) (bytesRemoved uint64, err error)
FileByHash(ctx context.Context, hash string) (File, error)
FileAdd(ctx context.Context, opts ...files2.AddOption) (File, error)
FileGetKeys(hash string) (*files2.FileKeys, error)
FileStoreKeys(fileKeys ...files2.FileKeys) error
FileAdd(ctx context.Context, opts ...files.AddOption) (File, error)
FileGetKeys(hash string) (*files.FileKeys, error)
FileStoreKeys(fileKeys ...files.FileKeys) error
ImageByHash(ctx context.Context, hash string) (Image, error)
ImageAdd(ctx context.Context, opts ...files2.AddOption) (Image, error)
ImageAdd(ctx context.Context, opts ...files.AddOption) (Image, error)
GetAllWorkspaces() ([]string, error)
GetWorkspaceIdForObject(objectId string) (string, error)
@ -67,11 +69,10 @@ type ObjectsDeriver interface {
}
type Anytype struct {
files *files2.Service
objectStore objectstore.ObjectStore
fileStore filestore.FileStore
fileBlockStorage filestorage.FileStorage
deriver ObjectsDeriver
files *files.Service
objectStore objectstore.ObjectStore
fileStore filestore.FileStore
deriver ObjectsDeriver
predefinedBlockIds threads.DerivedSmartblockIds
@ -99,10 +100,9 @@ func (a *Anytype) Init(ap *app.App) (err error) {
a.config = ap.MustComponent(config.CName).(*config.Config)
a.objectStore = ap.MustComponent(objectstore.CName).(objectstore.ObjectStore)
a.fileStore = ap.MustComponent(filestore.CName).(filestore.FileStore)
a.files = ap.MustComponent(files2.CName).(*files2.Service)
a.files = ap.MustComponent(files.CName).(*files.Service)
a.commonFiles = ap.MustComponent(fileservice.CName).(fileservice.FileService)
a.deriver = ap.MustComponent(treegetter.CName).(ObjectsDeriver)
a.fileBlockStorage = app.MustComponent[filestorage.FileStorage](ap)
a.deriver = ap.MustComponent(treemanager.CName).(ObjectsDeriver)
return
}

View file

@ -57,6 +57,7 @@ func (l *localDiscovery) Init(a *app.App) (err error) {
}
func (l *localDiscovery) Run(ctx context.Context) (err error) {
return nil
l.port = l.portProvider.Port()
l.periodicCheck.Run()
return
@ -67,6 +68,7 @@ func (l *localDiscovery) Name() (name string) {
}
func (l *localDiscovery) Close(ctx context.Context) (err error) {
return nil
l.periodicCheck.Close()
l.cancel()
if l.server != nil {

View file

@ -113,6 +113,11 @@ func (s *spaceStorage) SpaceSettingsId() string {
return s.spaceSettingsId
}
func (s *spaceStorage) HasTree(id string) (bool, error) {
keys := newTreeKeys(s.spaceId, id)
return hasDB(s.objDb, keys.RootIdKey()), nil
}
func (s *spaceStorage) TreeStorage(id string) (storage.TreeStorage, error) {
return newTreeStorage(s.objDb, s.spaceId, id)
}