mirror of
https://github.com/anyproto/anytype-heart.git
synced 2025-06-10 01:51:07 +09:00
Merge pull request #1362 from anyproto/go-3687-fix-spaceoffload-hung
GO-3687 Fix spaceOffload hung
This commit is contained in:
commit
d3aa32a63d
8 changed files with 89 additions and 92 deletions
|
@ -127,6 +127,8 @@ type Space interface {
|
|||
|
||||
Do(objectId string, apply func(sb SmartBlock) error) error
|
||||
DoLockedIfNotExists(objectID string, proc func() error) error // TODO Temporarily before rewriting favorites/archive mechanism
|
||||
|
||||
StoredIds() []string
|
||||
}
|
||||
|
||||
type SmartBlock interface {
|
||||
|
|
|
@ -118,6 +118,10 @@ func (s *stubSpace) IsPersonal() bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func (s *stubSpace) StoredIds() []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (st *SmartTest) Space() smartblock.Space {
|
||||
if st.space != nil {
|
||||
return st.space
|
||||
|
|
|
@ -87,9 +87,9 @@ func (_c *MockService_DetailsFromIdBasedSource_Call) RunAndReturn(run func(strin
|
|||
return _c
|
||||
}
|
||||
|
||||
// IDsListerBySmartblockType provides a mock function with given fields: spaceID, blockType
|
||||
func (_m *MockService) IDsListerBySmartblockType(spaceID string, blockType smartblock.SmartBlockType) (source.IDsLister, error) {
|
||||
ret := _m.Called(spaceID, blockType)
|
||||
// IDsListerBySmartblockType provides a mock function with given fields: space, blockType
|
||||
func (_m *MockService) IDsListerBySmartblockType(space source.Space, blockType smartblock.SmartBlockType) (source.IDsLister, error) {
|
||||
ret := _m.Called(space, blockType)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for IDsListerBySmartblockType")
|
||||
|
@ -97,19 +97,19 @@ func (_m *MockService) IDsListerBySmartblockType(spaceID string, blockType smart
|
|||
|
||||
var r0 source.IDsLister
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string, smartblock.SmartBlockType) (source.IDsLister, error)); ok {
|
||||
return rf(spaceID, blockType)
|
||||
if rf, ok := ret.Get(0).(func(source.Space, smartblock.SmartBlockType) (source.IDsLister, error)); ok {
|
||||
return rf(space, blockType)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string, smartblock.SmartBlockType) source.IDsLister); ok {
|
||||
r0 = rf(spaceID, blockType)
|
||||
if rf, ok := ret.Get(0).(func(source.Space, smartblock.SmartBlockType) source.IDsLister); ok {
|
||||
r0 = rf(space, blockType)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(source.IDsLister)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(string, smartblock.SmartBlockType) error); ok {
|
||||
r1 = rf(spaceID, blockType)
|
||||
if rf, ok := ret.Get(1).(func(source.Space, smartblock.SmartBlockType) error); ok {
|
||||
r1 = rf(space, blockType)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
@ -123,15 +123,15 @@ type MockService_IDsListerBySmartblockType_Call struct {
|
|||
}
|
||||
|
||||
// IDsListerBySmartblockType is a helper method to define mock.On call
|
||||
// - spaceID string
|
||||
// - space source.Space
|
||||
// - blockType smartblock.SmartBlockType
|
||||
func (_e *MockService_Expecter) IDsListerBySmartblockType(spaceID interface{}, blockType interface{}) *MockService_IDsListerBySmartblockType_Call {
|
||||
return &MockService_IDsListerBySmartblockType_Call{Call: _e.mock.On("IDsListerBySmartblockType", spaceID, blockType)}
|
||||
func (_e *MockService_Expecter) IDsListerBySmartblockType(space interface{}, blockType interface{}) *MockService_IDsListerBySmartblockType_Call {
|
||||
return &MockService_IDsListerBySmartblockType_Call{Call: _e.mock.On("IDsListerBySmartblockType", space, blockType)}
|
||||
}
|
||||
|
||||
func (_c *MockService_IDsListerBySmartblockType_Call) Run(run func(spaceID string, blockType smartblock.SmartBlockType)) *MockService_IDsListerBySmartblockType_Call {
|
||||
func (_c *MockService_IDsListerBySmartblockType_Call) Run(run func(space source.Space, blockType smartblock.SmartBlockType)) *MockService_IDsListerBySmartblockType_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(string), args[1].(smartblock.SmartBlockType))
|
||||
run(args[0].(source.Space), args[1].(smartblock.SmartBlockType))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ func (_c *MockService_IDsListerBySmartblockType_Call) Return(_a0 source.IDsListe
|
|||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_IDsListerBySmartblockType_Call) RunAndReturn(run func(string, smartblock.SmartBlockType) (source.IDsLister, error)) *MockService_IDsListerBySmartblockType_Call {
|
||||
func (_c *MockService_IDsListerBySmartblockType_Call) RunAndReturn(run func(source.Space, smartblock.SmartBlockType) (source.IDsLister, error)) *MockService_IDsListerBySmartblockType_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ import (
|
|||
"github.com/anyproto/anytype-heart/pkg/lib/bundle"
|
||||
"github.com/anyproto/anytype-heart/pkg/lib/core/smartblock"
|
||||
"github.com/anyproto/anytype-heart/pkg/lib/localstore/addr"
|
||||
"github.com/anyproto/anytype-heart/space/spacecore"
|
||||
"github.com/anyproto/anytype-heart/space/spacecore/storage"
|
||||
"github.com/anyproto/anytype-heart/space/spacecore/typeprovider"
|
||||
)
|
||||
|
@ -45,6 +44,7 @@ type Space interface {
|
|||
GetRelationIdByKey(ctx context.Context, key domain.RelationKey) (id string, err error)
|
||||
GetTypeIdByKey(ctx context.Context, key domain.TypeKey) (id string, err error)
|
||||
DeriveObjectID(ctx context.Context, uniqueKey domain.UniqueKey) (id string, err error)
|
||||
StoredIds() []string
|
||||
}
|
||||
|
||||
type Service interface {
|
||||
|
@ -53,7 +53,7 @@ type Service interface {
|
|||
NewStaticSource(params StaticSourceParams) SourceWithType
|
||||
|
||||
DetailsFromIdBasedSource(id string) (*types.Struct, error)
|
||||
IDsListerBySmartblockType(spaceID string, blockType smartblock.SmartBlockType) (IDsLister, error)
|
||||
IDsListerBySmartblockType(space Space, blockType smartblock.SmartBlockType) (IDsLister, error)
|
||||
app.Component
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,6 @@ type service struct {
|
|||
sbtProvider typeprovider.SmartBlockTypeProvider
|
||||
accountService accountService
|
||||
accountKeysService accountservice.Service
|
||||
spaceCoreService spacecore.SpaceCoreService
|
||||
storageService storage.ClientStorage
|
||||
fileService files.Service
|
||||
objectStore RelationGetter
|
||||
|
@ -77,7 +76,6 @@ func (s *service) Init(a *app.App) (err error) {
|
|||
s.sbtProvider = a.MustComponent(typeprovider.CName).(typeprovider.SmartBlockTypeProvider)
|
||||
s.accountService = app.MustComponent[accountService](a)
|
||||
s.accountKeysService = a.MustComponent(accountservice.CName).(accountservice.Service)
|
||||
s.spaceCoreService = app.MustComponent[spacecore.SpaceCoreService](a)
|
||||
s.storageService = a.MustComponent(spacestorage.CName).(storage.ClientStorage)
|
||||
|
||||
s.fileService = app.MustComponent[files.Service](a)
|
||||
|
@ -160,7 +158,7 @@ func (s *service) newSource(ctx context.Context, space Space, id string, buildOp
|
|||
return s.newTreeSource(ctx, space, id, buildOptions.BuildTreeOpts())
|
||||
}
|
||||
|
||||
func (s *service) IDsListerBySmartblockType(spaceID string, blockType smartblock.SmartBlockType) (IDsLister, error) {
|
||||
func (s *service) IDsListerBySmartblockType(space Space, blockType smartblock.SmartBlockType) (IDsLister, error) {
|
||||
switch blockType {
|
||||
case smartblock.SmartBlockTypeAnytypeProfile:
|
||||
return &anytypeProfile{}, nil
|
||||
|
@ -181,9 +179,9 @@ func (s *service) IDsListerBySmartblockType(spaceID string, blockType smartblock
|
|||
return nil, err
|
||||
}
|
||||
return &source{
|
||||
spaceID: spaceID,
|
||||
space: space,
|
||||
spaceID: space.Id(),
|
||||
smartblockType: blockType,
|
||||
spaceService: s.spaceCoreService,
|
||||
sbtProvider: s.sbtProvider,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ import (
|
|||
"github.com/anyproto/anytype-heart/pkg/lib/core/smartblock"
|
||||
"github.com/anyproto/anytype-heart/pkg/lib/logging"
|
||||
"github.com/anyproto/anytype-heart/pkg/lib/pb/model"
|
||||
"github.com/anyproto/anytype-heart/space/spacecore"
|
||||
"github.com/anyproto/anytype-heart/space/spacecore/typeprovider"
|
||||
"github.com/anyproto/anytype-heart/util/slice"
|
||||
)
|
||||
|
@ -152,7 +151,6 @@ func (s *service) newTreeSource(ctx context.Context, space Space, id string, bui
|
|||
id: id,
|
||||
space: space,
|
||||
spaceID: space.Id(),
|
||||
spaceService: s.spaceCoreService,
|
||||
smartblockType: sbt,
|
||||
accountService: s.accountService,
|
||||
accountKeysService: s.accountKeysService,
|
||||
|
@ -191,7 +189,6 @@ type source struct {
|
|||
fileService files.Service
|
||||
accountService accountService
|
||||
accountKeysService accountservice.Service
|
||||
spaceService spacecore.SpaceCoreService
|
||||
sbtProvider typeprovider.SmartBlockTypeProvider
|
||||
objectStore RelationGetter
|
||||
fileObjectMigrator fileObjectMigrator
|
||||
|
@ -418,11 +415,10 @@ func checkChangeSize(data []byte, maxSize int) error {
|
|||
}
|
||||
|
||||
func (s *source) ListIds() (ids []string, err error) {
|
||||
spc, err := s.spaceService.Get(context.Background(), s.spaceID)
|
||||
if err != nil {
|
||||
if s.space == nil {
|
||||
return
|
||||
}
|
||||
ids = slice.Filter(spc.StoredIds(), func(id string) bool {
|
||||
ids = slice.Filter(s.space.StoredIds(), func(id string) bool {
|
||||
t, err := s.sbtProvider.Type(s.spaceID, id)
|
||||
if err != nil {
|
||||
return false
|
||||
|
|
|
@ -19,7 +19,7 @@ import (
|
|||
"github.com/anyproto/anytype-heart/core/syncstatus/detailsupdater/helper"
|
||||
"github.com/anyproto/anytype-heart/metrics"
|
||||
"github.com/anyproto/anytype-heart/pkg/lib/bundle"
|
||||
smartblock2 "github.com/anyproto/anytype-heart/pkg/lib/core/smartblock"
|
||||
coresb "github.com/anyproto/anytype-heart/pkg/lib/core/smartblock"
|
||||
"github.com/anyproto/anytype-heart/pkg/lib/database"
|
||||
"github.com/anyproto/anytype-heart/pkg/lib/localstore/addr"
|
||||
"github.com/anyproto/anytype-heart/pkg/lib/pb/model"
|
||||
|
@ -120,7 +120,7 @@ func (i *indexer) ReindexSpace(space clientspace.Space) (err error) {
|
|||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = i.removeCommonIndexes(space.Id(), flags)
|
||||
err = i.removeCommonIndexes(space.Id(), space, flags)
|
||||
if err != nil {
|
||||
return fmt.Errorf("remove common indexes: %w", err)
|
||||
}
|
||||
|
@ -134,25 +134,22 @@ func (i *indexer) ReindexSpace(space clientspace.Space) (err error) {
|
|||
// for all ids except home and archive setting cache timeout for reindexing
|
||||
// ctx = context.WithValue(ctx, ocache.CacheTimeout, cacheTimeout)
|
||||
if flags.objects {
|
||||
types := []smartblock2.SmartBlockType{
|
||||
types := []coresb.SmartBlockType{
|
||||
// System types first
|
||||
smartblock2.SmartBlockTypeObjectType,
|
||||
smartblock2.SmartBlockTypeRelation,
|
||||
smartblock2.SmartBlockTypeRelationOption,
|
||||
smartblock2.SmartBlockTypeFileObject,
|
||||
coresb.SmartBlockTypeObjectType,
|
||||
coresb.SmartBlockTypeRelation,
|
||||
coresb.SmartBlockTypeRelationOption,
|
||||
coresb.SmartBlockTypeFileObject,
|
||||
|
||||
smartblock2.SmartBlockTypePage,
|
||||
smartblock2.SmartBlockTypeTemplate,
|
||||
smartblock2.SmartBlockTypeArchive,
|
||||
smartblock2.SmartBlockTypeHome,
|
||||
smartblock2.SmartBlockTypeWorkspace,
|
||||
smartblock2.SmartBlockTypeSpaceView,
|
||||
smartblock2.SmartBlockTypeProfilePage,
|
||||
coresb.SmartBlockTypePage,
|
||||
coresb.SmartBlockTypeTemplate,
|
||||
coresb.SmartBlockTypeArchive,
|
||||
coresb.SmartBlockTypeHome,
|
||||
coresb.SmartBlockTypeWorkspace,
|
||||
coresb.SmartBlockTypeSpaceView,
|
||||
coresb.SmartBlockTypeProfilePage,
|
||||
}
|
||||
ids, err := i.getIdsForTypes(
|
||||
space.Id(),
|
||||
types...,
|
||||
)
|
||||
ids, err := i.getIdsForTypes(space, types...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -169,7 +166,7 @@ func (i *indexer) ReindexSpace(space clientspace.Space) (err error) {
|
|||
} else {
|
||||
|
||||
if flags.fileObjects {
|
||||
err := i.reindexIDsForSmartblockTypes(ctx, space, metrics.ReindexTypeFiles, smartblock2.SmartBlockTypeFileObject)
|
||||
err := i.reindexIDsForSmartblockTypes(ctx, space, metrics.ReindexTypeFiles, coresb.SmartBlockTypeFileObject)
|
||||
if err != nil {
|
||||
return fmt.Errorf("reindex file objects: %w", err)
|
||||
}
|
||||
|
@ -216,7 +213,7 @@ func (i *indexer) addSyncDetails(space clientspace.Space) {
|
|||
syncStatus = domain.ObjectError
|
||||
syncError = domain.NetworkError
|
||||
}
|
||||
ids, err := i.getIdsForTypes(space.Id(), typesForSyncRelations...)
|
||||
ids, err := i.getIdsForTypes(space, typesForSyncRelations...)
|
||||
if err != nil {
|
||||
log.Debug("failed to add sync status relations", zap.Error(err))
|
||||
}
|
||||
|
@ -314,7 +311,7 @@ func (i *indexer) ReindexMarketplaceSpace(space clientspace.Space) error {
|
|||
}
|
||||
|
||||
if flags.removeAllIndexedObjects {
|
||||
_, err = i.removeDetails(space.Id())
|
||||
err = i.removeDetails(space.Id())
|
||||
if err != nil {
|
||||
return fmt.Errorf("remove details for marketplace space: %w", err)
|
||||
}
|
||||
|
@ -323,13 +320,13 @@ func (i *indexer) ReindexMarketplaceSpace(space clientspace.Space) error {
|
|||
ctx := context.Background()
|
||||
|
||||
if flags.bundledRelations {
|
||||
err = i.reindexIDsForSmartblockTypes(ctx, space, metrics.ReindexTypeBundledRelations, smartblock2.SmartBlockTypeBundledRelation)
|
||||
err = i.reindexIDsForSmartblockTypes(ctx, space, metrics.ReindexTypeBundledRelations, coresb.SmartBlockTypeBundledRelation)
|
||||
if err != nil {
|
||||
return fmt.Errorf("reindex bundled relations: %w", err)
|
||||
}
|
||||
}
|
||||
if flags.bundledTypes {
|
||||
err = i.reindexIDsForSmartblockTypes(ctx, space, metrics.ReindexTypeBundledTypes, smartblock2.SmartBlockTypeBundledObjectType, smartblock2.SmartBlockTypeAnytypeProfile)
|
||||
err = i.reindexIDsForSmartblockTypes(ctx, space, metrics.ReindexTypeBundledTypes, coresb.SmartBlockTypeBundledObjectType, coresb.SmartBlockTypeAnytypeProfile)
|
||||
if err != nil {
|
||||
return fmt.Errorf("reindex bundled types: %w", err)
|
||||
}
|
||||
|
@ -355,7 +352,7 @@ func (i *indexer) ReindexMarketplaceSpace(space clientspace.Space) error {
|
|||
}
|
||||
}
|
||||
|
||||
err = i.reindexIDsForSmartblockTypes(ctx, space, metrics.ReindexTypeBundledTemplates, smartblock2.SmartBlockTypeBundledTemplate)
|
||||
err = i.reindexIDsForSmartblockTypes(ctx, space, metrics.ReindexTypeBundledTemplates, coresb.SmartBlockTypeBundledTemplate)
|
||||
if err != nil {
|
||||
return fmt.Errorf("reindex bundled templates: %w", err)
|
||||
}
|
||||
|
@ -367,13 +364,13 @@ func (i *indexer) ReindexMarketplaceSpace(space clientspace.Space) error {
|
|||
return i.saveLatestChecksums(space.Id())
|
||||
}
|
||||
|
||||
func (i *indexer) removeDetails(spaceId string) (ids []string, err error) {
|
||||
err = i.removeOldObjects()
|
||||
func (i *indexer) removeDetails(spaceId string) error {
|
||||
err := i.removeOldObjects()
|
||||
if err != nil {
|
||||
err = nil
|
||||
log.Errorf("reindex failed to removeOldObjects: %v", err)
|
||||
}
|
||||
ids, err = i.store.ListIdsBySpace(spaceId)
|
||||
ids, err := i.store.ListIdsBySpace(spaceId)
|
||||
if err != nil {
|
||||
log.Errorf("reindex failed to get all ids(removeAllIndexedObjects): %v", err)
|
||||
}
|
||||
|
@ -382,7 +379,7 @@ func (i *indexer) removeDetails(spaceId string) (ids []string, err error) {
|
|||
log.Errorf("reindex failed to delete details(removeAllIndexedObjects): %v", err)
|
||||
}
|
||||
}
|
||||
return ids, err
|
||||
return err
|
||||
}
|
||||
|
||||
// removeOldObjects removes all objects that are not supported anymore (e.g. old subobjects) and no longer returned by the underlying source
|
||||
|
@ -413,7 +410,7 @@ func (i *indexer) removeOldObjects() (err error) {
|
|||
return err
|
||||
}
|
||||
|
||||
func (i *indexer) removeCommonIndexes(spaceId string, flags reindexFlags) (err error) {
|
||||
func (i *indexer) removeCommonIndexes(spaceId string, space clientspace.Space, flags reindexFlags) (err error) {
|
||||
if flags.any() {
|
||||
log.Infof("start store reindex (%s)", flags.String())
|
||||
}
|
||||
|
@ -427,38 +424,38 @@ func (i *indexer) removeCommonIndexes(spaceId string, flags reindexFlags) (err e
|
|||
}
|
||||
}
|
||||
|
||||
var ids []string
|
||||
if flags.removeAllIndexedObjects {
|
||||
flags.eraseLinks = true
|
||||
ids, err = i.removeDetails(spaceId)
|
||||
}
|
||||
|
||||
if flags.eraseLinks {
|
||||
var virtualObjectIds []string
|
||||
if len(ids) == 0 {
|
||||
ids, err = i.store.ListIdsBySpace(spaceId)
|
||||
}
|
||||
ids, err := i.store.ListIdsBySpace(spaceId)
|
||||
if err != nil {
|
||||
log.Errorf("reindex failed to get all ids(eraseLinks): %v", err)
|
||||
}
|
||||
|
||||
// we get ids of Home and Archive separately from other objects,
|
||||
// because we do not index its details, so it could not be fetched via store.Query
|
||||
virtualObjectIds, err = i.getIdsForTypes(spaceId, smartblock2.SmartBlockTypeHome, smartblock2.SmartBlockTypeArchive)
|
||||
if err != nil {
|
||||
log.Errorf("reindex: failed to get ids of virtual objects (eraseLinks): %v", err)
|
||||
if space != nil {
|
||||
homeAndArchive, err := i.getIdsForTypes(space, coresb.SmartBlockTypeHome, coresb.SmartBlockTypeArchive)
|
||||
if err != nil {
|
||||
log.Errorf("reindex: failed to get ids of home and archive (eraseLinks): %v", err)
|
||||
}
|
||||
ids = append(ids, homeAndArchive...)
|
||||
}
|
||||
for _, id := range append(ids, virtualObjectIds...) {
|
||||
|
||||
for _, id := range ids {
|
||||
if err = i.store.DeleteLinks(id); err != nil {
|
||||
log.Errorf("reindex failed to delete links(eraseLinks): %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if flags.removeAllIndexedObjects {
|
||||
err = i.removeDetails(spaceId)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (i *indexer) reindexIDsForSmartblockTypes(ctx context.Context, space smartblock.Space, reindexType metrics.ReindexType, sbTypes ...smartblock2.SmartBlockType) error {
|
||||
ids, err := i.getIdsForTypes(space.Id(), sbTypes...)
|
||||
func (i *indexer) reindexIDsForSmartblockTypes(ctx context.Context, space smartblock.Space, reindexType metrics.ReindexType, sbTypes ...coresb.SmartBlockType) error {
|
||||
ids, err := i.getIdsForTypes(space, sbTypes...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -548,10 +545,10 @@ func (i *indexer) saveLatestChecksums(spaceID string) error {
|
|||
return i.store.SaveChecksums(spaceID, &checksums)
|
||||
}
|
||||
|
||||
func (i *indexer) getIdsForTypes(spaceID string, sbt ...smartblock2.SmartBlockType) ([]string, error) {
|
||||
func (i *indexer) getIdsForTypes(space smartblock.Space, sbt ...coresb.SmartBlockType) ([]string, error) {
|
||||
var ids []string
|
||||
for _, t := range sbt {
|
||||
lister, err := i.source.IDsListerBySmartblockType(spaceID, t)
|
||||
lister, err := i.source.IDsListerBySmartblockType(space, t)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -594,5 +591,5 @@ func (i *indexer) logFinishedReindexStat(reindexType metrics.ReindexType, totalI
|
|||
func (i *indexer) RemoveIndexes(spaceId string) error {
|
||||
var flags reindexFlags
|
||||
flags.enableAll()
|
||||
return i.removeCommonIndexes(spaceId, flags)
|
||||
return i.removeCommonIndexes(spaceId, nil, flags)
|
||||
}
|
||||
|
|
|
@ -205,7 +205,7 @@ func TestIndexer_ReindexSpace_EraseLinks(t *testing.T) {
|
|||
fx := NewIndexerFixture(t)
|
||||
|
||||
fx.sourceFx.EXPECT().IDsListerBySmartblockType(mock.Anything, mock.Anything).RunAndReturn(
|
||||
func(_ string, sbt coresb.SmartBlockType) (source.IDsLister, error) {
|
||||
func(_ source.Space, sbt coresb.SmartBlockType) (source.IDsLister, error) {
|
||||
switch sbt {
|
||||
case coresb.SmartBlockTypeHome:
|
||||
return idsLister{Ids: []string{"home"}}, nil
|
||||
|
@ -376,13 +376,13 @@ func TestReindex_addSyncRelations(t *testing.T) {
|
|||
space1.EXPECT().Id().Return(spaceId1)
|
||||
space1.EXPECT().StoredIds().Return([]string{})
|
||||
|
||||
fx.sourceFx.EXPECT().IDsListerBySmartblockType(spaceId1, coresb.SmartBlockTypePage).Return(idsLister{Ids: []string{"1", "2"}}, nil)
|
||||
fx.sourceFx.EXPECT().IDsListerBySmartblockType(spaceId1, coresb.SmartBlockTypeRelation).Return(idsLister{Ids: []string{}}, nil)
|
||||
fx.sourceFx.EXPECT().IDsListerBySmartblockType(spaceId1, coresb.SmartBlockTypeRelationOption).Return(idsLister{Ids: []string{}}, nil)
|
||||
fx.sourceFx.EXPECT().IDsListerBySmartblockType(spaceId1, coresb.SmartBlockTypeFileObject).Return(idsLister{Ids: []string{}}, nil)
|
||||
fx.sourceFx.EXPECT().IDsListerBySmartblockType(spaceId1, coresb.SmartBlockTypeObjectType).Return(idsLister{Ids: []string{}}, nil)
|
||||
fx.sourceFx.EXPECT().IDsListerBySmartblockType(spaceId1, coresb.SmartBlockTypeTemplate).Return(idsLister{Ids: []string{}}, nil)
|
||||
fx.sourceFx.EXPECT().IDsListerBySmartblockType(spaceId1, coresb.SmartBlockTypeProfilePage).Return(idsLister{Ids: []string{}}, nil)
|
||||
fx.sourceFx.EXPECT().IDsListerBySmartblockType(space1, coresb.SmartBlockTypePage).Return(idsLister{Ids: []string{"1", "2"}}, nil)
|
||||
fx.sourceFx.EXPECT().IDsListerBySmartblockType(space1, coresb.SmartBlockTypeRelation).Return(idsLister{Ids: []string{}}, nil)
|
||||
fx.sourceFx.EXPECT().IDsListerBySmartblockType(space1, coresb.SmartBlockTypeRelationOption).Return(idsLister{Ids: []string{}}, nil)
|
||||
fx.sourceFx.EXPECT().IDsListerBySmartblockType(space1, coresb.SmartBlockTypeFileObject).Return(idsLister{Ids: []string{}}, nil)
|
||||
fx.sourceFx.EXPECT().IDsListerBySmartblockType(space1, coresb.SmartBlockTypeObjectType).Return(idsLister{Ids: []string{}}, nil)
|
||||
fx.sourceFx.EXPECT().IDsListerBySmartblockType(space1, coresb.SmartBlockTypeTemplate).Return(idsLister{Ids: []string{}}, nil)
|
||||
fx.sourceFx.EXPECT().IDsListerBySmartblockType(space1, coresb.SmartBlockTypeProfilePage).Return(idsLister{Ids: []string{}}, nil)
|
||||
|
||||
space1.EXPECT().DoLockedIfNotExists("1", mock.AnythingOfType("func() error")).Return(nil)
|
||||
space1.EXPECT().DoLockedIfNotExists("2", mock.AnythingOfType("func() error")).Return(nil)
|
||||
|
@ -414,13 +414,13 @@ func TestReindex_addSyncRelations(t *testing.T) {
|
|||
space1.EXPECT().Id().Return(spaceId1)
|
||||
space1.EXPECT().StoredIds().Return([]string{})
|
||||
|
||||
fx.sourceFx.EXPECT().IDsListerBySmartblockType(spaceId1, coresb.SmartBlockTypePage).Return(idsLister{Ids: []string{"1", "2"}}, nil)
|
||||
fx.sourceFx.EXPECT().IDsListerBySmartblockType(spaceId1, coresb.SmartBlockTypeRelation).Return(idsLister{Ids: []string{}}, nil)
|
||||
fx.sourceFx.EXPECT().IDsListerBySmartblockType(spaceId1, coresb.SmartBlockTypeRelationOption).Return(idsLister{Ids: []string{}}, nil)
|
||||
fx.sourceFx.EXPECT().IDsListerBySmartblockType(spaceId1, coresb.SmartBlockTypeFileObject).Return(idsLister{Ids: []string{}}, nil)
|
||||
fx.sourceFx.EXPECT().IDsListerBySmartblockType(spaceId1, coresb.SmartBlockTypeObjectType).Return(idsLister{Ids: []string{}}, nil)
|
||||
fx.sourceFx.EXPECT().IDsListerBySmartblockType(spaceId1, coresb.SmartBlockTypeTemplate).Return(idsLister{Ids: []string{}}, nil)
|
||||
fx.sourceFx.EXPECT().IDsListerBySmartblockType(spaceId1, coresb.SmartBlockTypeProfilePage).Return(idsLister{Ids: []string{}}, nil)
|
||||
fx.sourceFx.EXPECT().IDsListerBySmartblockType(space1, coresb.SmartBlockTypePage).Return(idsLister{Ids: []string{"1", "2"}}, nil)
|
||||
fx.sourceFx.EXPECT().IDsListerBySmartblockType(space1, coresb.SmartBlockTypeRelation).Return(idsLister{Ids: []string{}}, nil)
|
||||
fx.sourceFx.EXPECT().IDsListerBySmartblockType(space1, coresb.SmartBlockTypeRelationOption).Return(idsLister{Ids: []string{}}, nil)
|
||||
fx.sourceFx.EXPECT().IDsListerBySmartblockType(space1, coresb.SmartBlockTypeFileObject).Return(idsLister{Ids: []string{}}, nil)
|
||||
fx.sourceFx.EXPECT().IDsListerBySmartblockType(space1, coresb.SmartBlockTypeObjectType).Return(idsLister{Ids: []string{}}, nil)
|
||||
fx.sourceFx.EXPECT().IDsListerBySmartblockType(space1, coresb.SmartBlockTypeTemplate).Return(idsLister{Ids: []string{}}, nil)
|
||||
fx.sourceFx.EXPECT().IDsListerBySmartblockType(space1, coresb.SmartBlockTypeProfilePage).Return(idsLister{Ids: []string{}}, nil)
|
||||
|
||||
space1.EXPECT().DoLockedIfNotExists("1", mock.AnythingOfType("func() error")).Return(nil)
|
||||
space1.EXPECT().DoLockedIfNotExists("2", mock.AnythingOfType("func() error")).Return(nil)
|
||||
|
|
|
@ -61,7 +61,7 @@ func (mr *MockServiceMockRecorder) DetailsFromIdBasedSource(arg0 any) *gomock.Ca
|
|||
}
|
||||
|
||||
// IDsListerBySmartblockType mocks base method.
|
||||
func (m *MockService) IDsListerBySmartblockType(arg0 string, arg1 smartblock.SmartBlockType) (source.IDsLister, error) {
|
||||
func (m *MockService) IDsListerBySmartblockType(arg0 source.Space, arg1 smartblock.SmartBlockType) (source.IDsLister, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "IDsListerBySmartblockType", arg0, arg1)
|
||||
ret0, _ := ret[0].(source.IDsLister)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue