diff --git a/.golangci.yml b/.golangci.yml index 6ae332ab0..d5741ee21 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -9,6 +9,8 @@ run: go: '1.22' linters-settings: + unused: + field-writes-are-uses: false errcheck: check-blank: true errchkjson: diff --git a/Makefile b/Makefile index 0859b2fc1..2fda83852 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ CLIENT_ANDROID_PATH ?= ../anytype-kotlin CLIENT_IOS_PATH ?= ../anytype-swift BUILD_FLAGS ?= -export GOLANGCI_LINT_VERSION=v1.54.2 +export GOLANGCI_LINT_VERSION=1.58.1 export CGO_CFLAGS=-Wno-deprecated-non-prototype -Wno-unknown-warning-option -Wno-deprecated-declarations -Wno-xor-used-as-pow -Wno-single-bit-bitfield-constant-conversion ifndef $(GOPATH) diff --git a/cmd/archiveunpacker/main.go b/cmd/archiveunpacker/main.go index 450e7855e..c2db3383e 100644 --- a/cmd/archiveunpacker/main.go +++ b/cmd/archiveunpacker/main.go @@ -139,40 +139,6 @@ func handleZip(input, output string) { } } -func handleDirectory(input, output string) { - err := filepath.Walk(input, func(path string, info os.FileInfo, err error) error { - if err != nil { - return err - } - - if !info.IsDir() { - // Get relative path - rel, err := filepath.Rel(input, path) - if err != nil { - return err - } - - outputFile := filepath.Join(output, rel) - - f, err := os.Open(path) - if err != nil { - return err - } - - processFile(File{ - Name: f.Name(), - RC: f, - }, outputFile) - } - - return nil - }) - - if err != nil { - log.Fatalf("Failed to process directory: %v", err) - } -} - func createZipFromDirectory(input, output string) { // create a new zip file newZipFile, err := os.Create(output) diff --git a/cmd/usecasevalidator/validators.go b/cmd/usecasevalidator/validators.go index 21c3c4556..5c921e5a2 100644 --- a/cmd/usecasevalidator/validators.go +++ b/cmd/usecasevalidator/validators.go @@ -7,7 +7,6 @@ import ( "strings" "github.com/hashicorp/go-multierror" - "github.com/ipfs/go-cid" "github.com/samber/lo" "github.com/anyproto/anytype-heart/core/block/editor/widget" @@ -214,39 +213,6 @@ func validateBlockLinks(s *pb.SnapshotWithType, info *useCaseInfo) (err error) { return err } -func validateFileKeys(s *pb.SnapshotWithType, _ *useCaseInfo) (err error) { - id := pbtypes.GetString(s.Snapshot.Data.Details, bundle.RelationKeyId.String()) - for _, r := range s.Snapshot.Data.RelationLinks { - if r.Format == model.RelationFormat_file || r.Key == bundle.RelationKeyCoverId.String() { - for _, hash := range pbtypes.GetStringList(s.Snapshot.GetData().GetDetails(), r.Key) { - if r.Format != model.RelationFormat_file { - _, err := cid.Parse(hash) - if err != nil { - continue - } - } - if !snapshotHasKeyForHash(s, hash) { - err = multierror.Append(err, fmt.Errorf("object '%s' has file detail '%s' has hash '%s' which keys are not in the snapshot", id, r.Key, hash)) - } - } - } - } - for _, b := range s.Snapshot.Data.Blocks { - if v, ok := simple.New(b).(simple.FileHashes); ok { - hashes := v.FillFileHashes([]string{}) - if len(hashes) == 0 { - continue - } - for _, hash := range hashes { - if !snapshotHasKeyForHash(s, hash) { - err = multierror.Append(err, fmt.Errorf("file block '%s' of object '%s' has hash '%s' which keys are not in the snapshot", b.Id, id, hash)) - } - } - } - } - return err -} - func validateDeleted(s *pb.SnapshotWithType, _ *useCaseInfo) error { id := pbtypes.GetString(s.Snapshot.Data.Details, bundle.RelationKeyId.String()) @@ -294,15 +260,6 @@ func getRelationLinkByKey(links []*model.RelationLink, key string) *model.Relati return nil } -func snapshotHasKeyForHash(s *pb.SnapshotWithType, hash string) bool { - for _, k := range s.Snapshot.FileKeys { - if k.Hash == hash && len(k.Keys) > 0 { - return true - } - } - return false -} - func isLinkRelation(k string) bool { return k == bundle.RelationKeyLinks.String() || k == bundle.RelationKeySourceObject.String() || k == bundle.RelationKeyBacklinks.String() } diff --git a/core/anytype/account/service.go b/core/anytype/account/service.go index ed0acf8ad..15d231d8f 100644 --- a/core/anytype/account/service.go +++ b/core/anytype/account/service.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "path/filepath" - "sync" "github.com/anyproto/any-sync/accountservice" "github.com/anyproto/any-sync/app" @@ -59,7 +58,6 @@ type service struct { coordClient coordinatorclient.CoordinatorClient picker cache.ObjectGetter - once sync.Once personalSpaceId string } diff --git a/core/block/editor/clipboard/clipboard_helpers_test.go b/core/block/editor/clipboard/clipboard_helpers_test.go index fbd5430be..68565d07e 100644 --- a/core/block/editor/clipboard/clipboard_helpers_test.go +++ b/core/block/editor/clipboard/clipboard_helpers_test.go @@ -22,8 +22,6 @@ import ( var emptyMarks [][]*model.BlockContentTextMark var bold = model.BlockContentTextMark_Bold -var italic = model.BlockContentTextMark_Italic -var fontRed = model.BlockContentTextMark_TextColor func page(blocks ...*model.Block) (sb *smarttest.SmartTest) { sb = smarttest.New("test") @@ -116,23 +114,6 @@ func shouldBe(sb *smarttest.SmartTest, t *testing.T, shouldBeBLocks ...*model.Bl } } -func shouldBeDebug(sb *smarttest.SmartTest, t *testing.T, shouldBeBLocks ...*model.Block) { - realBlocks := []*model.Block{} - cIds := sb.Pick("test").Model().ChildrenIds - for _, cId := range cIds { - realBlocks = append(realBlocks, sb.Pick(cId).Model()) - } - fmt.Println(len(realBlocks), len(shouldBeBLocks)) - - for i, realBlock := range realBlocks { - fmt.Println("Real ", i, realBlock) - } - - for i, b := range shouldBeBLocks { - fmt.Println("Should ", i, b) - } -} - func createBlocks(idsArr []string, textArr []string, marksArr [][]*model.BlockContentTextMark) []*model.Block { blocks := []*model.Block{} for i := 0; i < len(textArr); i++ { @@ -199,18 +180,6 @@ func checkBlockText(t *testing.T, sb *smarttest.SmartTest, textArr []string) { assert.Equal(t, textArr, textArr2) } -func checkBlockTextDebug(t *testing.T, sb *smarttest.SmartTest, textArr []string) { - for i, _ := range textArr { - fmt.Println(textArr[i]) - } - - fmt.Println("--------") - cIds := sb.Pick("test").Model().ChildrenIds - for _, c := range cIds { - fmt.Println("ID:", sb.Pick(c).Model().Id, "cId:", c, "Text:", sb.Pick(c).Model().GetText()) - } -} - func checkBlockMarks(t *testing.T, sb *smarttest.SmartTest, marksArr [][]*model.BlockContentTextMark) { cIds := sb.Pick("test").Model().ChildrenIds require.Equal(t, len(cIds), len(marksArr)) diff --git a/core/block/editor/dataview/dataview.go b/core/block/editor/dataview/dataview.go index a86107496..b57c65026 100644 --- a/core/block/editor/dataview/dataview.go +++ b/core/block/editor/dataview/dataview.go @@ -26,10 +26,7 @@ import ( "github.com/anyproto/anytype-heart/util/slice" ) -const DefaultDetailsFieldName = "_defaultRecordFields" - var log = logging.Logger("anytype-mw-editor-dataview") -var ErrMultiupdateWasNotAllowed = fmt.Errorf("multiupdate was not allowed") type Dataview interface { SetSource(ctx session.Context, blockId string, source []string) (err error) diff --git a/core/block/editor/smartblock/smartblock.go b/core/block/editor/smartblock/smartblock.go index 97037846b..32af05747 100644 --- a/core/block/editor/smartblock/smartblock.go +++ b/core/block/editor/smartblock/smartblock.go @@ -1196,14 +1196,6 @@ func (sb *smartBlock) AddHookOnce(id string, f HookCallback, events ...Hook) { } } -func (sb *smartBlock) baseRelations() []*model.Relation { - rels := []*model.Relation{bundle.MustGetRelation(bundle.RelationKeyId), bundle.MustGetRelation(bundle.RelationKeyLayout), bundle.MustGetRelation(bundle.RelationKeyIconEmoji), bundle.MustGetRelation(bundle.RelationKeyName)} - for _, rel := range rels { - rel.Scope = model.Relation_object - } - return rels -} - // deprecated, use RelationLinks instead func (sb *smartBlock) Relations(s *state.State) relationutils.Relations { var links []*model.RelationLink diff --git a/core/block/editor/state/normalize.go b/core/block/editor/state/normalize.go index ac3df6c68..af391b04f 100644 --- a/core/block/editor/state/normalize.go +++ b/core/block/editor/state/normalize.go @@ -14,8 +14,8 @@ import ( var ( maxChildrenThreshold = 40 - blockSizeLimit = 1 * 1024 * 1024 - detailSizeLimit = 65 * 1024 + + detailSizeLimit = 65 * 1024 ) func (s *State) Normalize(withLayouts bool) (err error) { diff --git a/core/block/editor/state/state_test.go b/core/block/editor/state/state_test.go index c29f9d56d..00b13bd74 100644 --- a/core/block/editor/state/state_test.go +++ b/core/block/editor/state/state_test.go @@ -2596,12 +2596,3 @@ func TestState_RootId(t *testing.T) { // assert.True(t, assertAllDetailsLessThenLimit(s.CombinedDetails())) // }) // } - -func assertAllDetailsLessThenLimit(details *types.Struct) bool { - for _, v := range details.Fields { - if v.Size() > detailSizeLimit { - return false - } - } - return true -} diff --git a/core/block/editor/stext/text.go b/core/block/editor/stext/text.go index c31ba96c2..e8ccbb059 100644 --- a/core/block/editor/stext/text.go +++ b/core/block/editor/stext/text.go @@ -25,8 +25,6 @@ import ( "github.com/anyproto/anytype-heart/util/slice" ) -const textSizeLimit = 64 * 1024 - var setTextApplyInterval = time.Second * 3 type Text interface { diff --git a/core/block/import/common/objectcreator/objectcreator.go b/core/block/import/common/objectcreator/objectcreator.go index 721ee9b7c..8da02c5f4 100644 --- a/core/block/import/common/objectcreator/objectcreator.go +++ b/core/block/import/common/objectcreator/objectcreator.go @@ -4,7 +4,6 @@ import ( "context" "errors" "fmt" - "sync" "github.com/anyproto/any-sync/commonspace/object/tree/treestorage" "github.com/gogo/protobuf/types" @@ -61,7 +60,6 @@ type ObjectCreator struct { syncFactory *syncer.Factory fileStore filestore.FileStore objectCreator objectcreator.Service - mu sync.Mutex } func New(service BlockService, diff --git a/core/block/import/markdown/anymark/html_to_blocks_test.go b/core/block/import/markdown/anymark/html_to_blocks_test.go index a5104f18d..bc540c5f8 100644 --- a/core/block/import/markdown/anymark/html_to_blocks_test.go +++ b/core/block/import/markdown/anymark/html_to_blocks_test.go @@ -14,11 +14,6 @@ import ( "github.com/anyproto/anytype-heart/pkg/lib/pb/model" ) -var ( - pasteCmdArgs = "pbpaste" - copyCmdArgs = "pbcopy" -) - type TestCase struct { Blocks []map[string]interface{} `json:"blocks"` HTML string `json:"html"` diff --git a/core/block/import/markdown/anymark/whitespace/normalize.go b/core/block/import/markdown/anymark/whitespace/normalize.go index 28e4c174a..fb9bfdbd8 100644 --- a/core/block/import/markdown/anymark/whitespace/normalize.go +++ b/core/block/import/markdown/anymark/whitespace/normalize.go @@ -36,31 +36,6 @@ var ( '\u205F': struct{}{}, // Medium mathemtical space. '\u3000': struct{}{}, // Ideographic space. } - - // Whitespace line replacement character map. - unicodeWhitespaceLineRepl = map[rune]struct{}{ - '\u0009': struct{}{}, // Character tabulation (HT.) - '\u000A': struct{}{}, // Line feed. - '\u0020': struct{}{}, // Space. - '\u00A0': struct{}{}, // No-break space. - '\u180E': struct{}{}, // Mongolian vowel separator. - '\u2000': struct{}{}, // En quad. - '\u2001': struct{}{}, // Em quad. - '\u2002': struct{}{}, // En space. - '\u2003': struct{}{}, // Em space. - '\u2004': struct{}{}, // Three-per-em space. - '\u2005': struct{}{}, // Four-per-em space. - '\u2006': struct{}{}, // Six-per-em space. - '\u2007': struct{}{}, // Figure space. - '\u2008': struct{}{}, // Punctuation space. - '\u2009': struct{}{}, // Thin space. - '\u200A': struct{}{}, // Hair space. - '\u2028': struct{}{}, // Line separator. - '\u2029': struct{}{}, // Paragraph separator. - '\u202F': struct{}{}, // Narrow no-break space. - '\u205F': struct{}{}, // Medium mathemtical space. - '\u3000': struct{}{}, // Ideographic space. - } ) // Normalize string. diff --git a/core/block/object/objectgraph/graph.go b/core/block/object/objectgraph/graph.go index 63695efb1..3f9eade48 100644 --- a/core/block/object/objectgraph/graph.go +++ b/core/block/object/objectgraph/graph.go @@ -40,7 +40,6 @@ type Service interface { } type Builder struct { - graphService Service //nolint:unused sbtProvider typeprovider.SmartBlockTypeProvider objectStore objectstore.ObjectStore subscriptionService subscription.Service diff --git a/core/block/object/treemanager/treemanager.go b/core/block/object/treemanager/treemanager.go index 3505aec4f..a8b97574b 100644 --- a/core/block/object/treemanager/treemanager.go +++ b/core/block/object/treemanager/treemanager.go @@ -2,7 +2,6 @@ package treemanager import ( "context" - "sync" "github.com/anyproto/any-sync/app" "github.com/anyproto/any-sync/commonspace/object/tree/objecttree" @@ -25,9 +24,6 @@ type treeManager struct { spaceService space.Service onDelete func(id domain.FullID) error - - syncStarted bool - syncerLock sync.Mutex } func New() treemanager.TreeManager { diff --git a/core/block/restriction/service.go b/core/block/restriction/service.go index 50619cb04..82ab5aff9 100644 --- a/core/block/restriction/service.go +++ b/core/block/restriction/service.go @@ -6,7 +6,6 @@ import ( "github.com/anyproto/any-sync/app" "github.com/anyproto/anytype-heart/pkg/lib/localstore/objectstore" - "github.com/anyproto/anytype-heart/pkg/lib/logging" "github.com/anyproto/anytype-heart/pkg/lib/pb/model" ) @@ -17,8 +16,6 @@ const ( var ( ErrRestricted = errors.New("restricted") - - log = logging.Logger("anytype-mw-restrictions") ) type Service interface { diff --git a/core/block/source/source.go b/core/block/source/source.go index 0330f3045..72a64614b 100644 --- a/core/block/source/source.go +++ b/core/block/source/source.go @@ -186,7 +186,6 @@ type source struct { changesSinceSnapshot int receiver ChangeReceiver unsubscribe func() - metaOnly bool closed chan struct{} openedAt time.Time diff --git a/core/files/debug.go b/core/files/debug.go index 207440ed6..27b5a0cf9 100644 --- a/core/files/debug.go +++ b/core/files/debug.go @@ -18,12 +18,6 @@ func (s *service) DebugRouter(r chi.Router) { r.Get("/tree/{rootID}", debug.PlaintextHandler(s.printTree)) } -type fileDebugInfo struct { - Hash string - SyncStatus int - IsIndexed bool -} - func (s *service) printTree(w io.Writer, req *http.Request) error { rawID := chi.URLParam(req, "rootID") id, err := cid.Parse(rawID) diff --git a/core/files/file.go b/core/files/file.go index 9054a7685..ff0f88736 100644 --- a/core/files/file.go +++ b/core/files/file.go @@ -34,15 +34,6 @@ type file struct { node *service } -func (s *service) newFile(spaceId string, fileId domain.FileId, info *storage.FileInfo) File { - return &file{ - spaceID: spaceId, - fileId: fileId, - info: info, - node: s, - } -} - type FileMeta struct { Media string Name string diff --git a/core/files/fileobject/fileindex.go b/core/files/fileobject/fileindex.go index 1e0585aca..fa003e42b 100644 --- a/core/files/fileobject/fileindex.go +++ b/core/files/fileobject/fileindex.go @@ -229,10 +229,6 @@ func (ind *indexer) injectMetadataToState(ctx context.Context, st *state.State, return nil } -func (ind *indexer) markFileAsNotFound(st *state.State) { - st.SetDetailAndBundledRelation(bundle.RelationKeyFileIndexingStatus, pbtypes.Int64(int64(model.FileIndexingStatus_NotFound))) -} - func (ind *indexer) buildDetails(ctx context.Context, id domain.FullFileId) (details *types.Struct, typeKey domain.TypeKey, err error) { file, err := ind.fileService.FileByHash(ctx, id) if err != nil { diff --git a/core/files/files.go b/core/files/files.go index 9e1cbbb57..a2af118b6 100644 --- a/core/files/files.go +++ b/core/files/files.go @@ -210,21 +210,6 @@ func (s *service) newExistingFileResult(lock *sync.Mutex, fileId domain.FileId) } -func (s *service) getFileIdAndEncryptionKeysFromInfo(fileInfo *storage.FileInfo) (domain.FileId, *domain.FileEncryptionKeys, error) { - if len(fileInfo.Targets) == 0 { - return "", nil, fmt.Errorf("file exists but has no root") - } - fileId := domain.FileId(fileInfo.Targets[0]) - keys, err := s.fileStore.GetFileKeys(fileId) - if err != nil { - return "", nil, fmt.Errorf("can't get encryption keys for existing file: %w", err) - } - return fileId, &domain.FileEncryptionKeys{ - FileId: fileId, - EncryptionKeys: keys, - }, nil -} - // addFileRootNode has structure: /* - dir (outer) diff --git a/core/files/fileuploader/uploader_test.go b/core/files/fileuploader/uploader_test.go index 443a4ec12..e74cfb5c2 100644 --- a/core/files/fileuploader/uploader_test.go +++ b/core/files/fileuploader/uploader_test.go @@ -34,7 +34,6 @@ import ( "github.com/anyproto/anytype-heart/pkg/lib/pb/model" "github.com/anyproto/anytype-heart/tests/testutil" "github.com/anyproto/anytype-heart/util/pbtypes" - "github.com/anyproto/anytype-heart/util/testMock" ) func TestUploader_Upload(t *testing.T) { @@ -250,19 +249,6 @@ type uplFixture struct { fileObjectService *mock_fileobject.MockService } -func (fx *uplFixture) newImage(fileId domain.FileId) *testMock.MockImage { - im := testMock.NewMockImage(fx.ctrl) - im.EXPECT().FileId().Return(fileId).AnyTimes() - return im -} - -func (fx *uplFixture) newFile(fileId domain.FileId, meta *files.FileMeta) *testMock.MockFile { - f := testMock.NewMockFile(fx.ctrl) - f.EXPECT().FileId().Return(fileId).AnyTimes() - f.EXPECT().Meta().Return(meta).AnyTimes() - return f -} - func (fx *uplFixture) tearDown() { fx.ctrl.Finish() } diff --git a/core/filestorage/fileservice.go b/core/filestorage/fileservice.go index 86bfed8e4..028cc3da4 100644 --- a/core/filestorage/fileservice.go +++ b/core/filestorage/fileservice.go @@ -22,7 +22,6 @@ import ( "github.com/anyproto/anytype-heart/core/event" "github.com/anyproto/anytype-heart/core/filestorage/rpcstore" "github.com/anyproto/anytype-heart/core/wallet" - "github.com/anyproto/anytype-heart/pkg/lib/datastore" "github.com/anyproto/anytype-heart/space/spacecore/storage" ) @@ -49,7 +48,6 @@ type fileStorage struct { cfg *config.Config flatfsPath string - provider datastore.Datastore rpcStore rpcstore.Service spaceStorage storage.ClientStorage eventSender event.Sender diff --git a/core/filestorage/filesync/stats_test.go b/core/filestorage/filesync/stats_test.go index e0d72702b..42ede9cef 100644 --- a/core/filestorage/filesync/stats_test.go +++ b/core/filestorage/filesync/stats_test.go @@ -9,10 +9,6 @@ import ( "github.com/anyproto/anytype-heart/pb" ) -type limitSetter interface { - SetLimit(limit int) -} - func TestSpaceUsageUpdate(t *testing.T) { const limit = 1024 * 1024 * 1024 fx := newFixture(t, limit) diff --git a/core/filestorage/rpcstore/store.go b/core/filestorage/rpcstore/store.go index fc27bf35f..9002d047d 100644 --- a/core/filestorage/rpcstore/store.go +++ b/core/filestorage/rpcstore/store.go @@ -3,7 +3,6 @@ package rpcstore import ( "context" "errors" - "sync" "github.com/anyproto/any-sync/commonfile/fileblockstore" "github.com/anyproto/any-sync/commonfile/fileproto" @@ -40,7 +39,6 @@ type RpcStore interface { type store struct { s *service cm *clientManager - mu sync.RWMutex backgroundCtx context.Context backgroundCancel context.CancelFunc diff --git a/core/indexer/indexer.go b/core/indexer/indexer.go index fbae26d9a..66dc2bc46 100644 --- a/core/indexer/indexer.go +++ b/core/indexer/indexer.go @@ -74,8 +74,6 @@ type indexer struct { indexedFiles *sync.Map reindexLogFields []zap.Field - - flags reindexFlags } func (i *indexer) Init(a *app.App) (err error) { diff --git a/go.mod b/go.mod index 957993560..5a44eb4fa 100644 --- a/go.mod +++ b/go.mod @@ -294,3 +294,6 @@ replace github.com/araddon/dateparse => github.com/mehanizm/dateparse v0.0.0-202 replace github.com/multiformats/go-multiaddr => github.com/anyproto/go-multiaddr v0.8.1-0.20221213144344-0b6b93adaec4 replace github.com/gogo/protobuf => github.com/anyproto/protobuf v1.3.3-0.20240201225420-6e325cf0ac38 + +replace github.com/anyproto/any-sync => /Users/mikhailyudin/GolandProjects/any-sync2 + diff --git a/pkg/lib/core/core.go b/pkg/lib/core/core.go index bcf58a3e7..eece10cbb 100644 --- a/pkg/lib/core/core.go +++ b/pkg/lib/core/core.go @@ -29,13 +29,11 @@ var _ app.Component = (*Anytype)(nil) var _ Service = (*Anytype)(nil) type Anytype struct { - migrationOnce sync.Once lock sync.RWMutex isStarted bool // use under the lock shutdownStartsCh chan struct { } // closed when node shutdown starts - subscribeOnce sync.Once } func New() *Anytype { diff --git a/pkg/lib/database/database.go b/pkg/lib/database/database.go index 1dfc1513a..3f8ab8853 100644 --- a/pkg/lib/database/database.go +++ b/pkg/lib/database/database.go @@ -224,10 +224,6 @@ func (f *Filters) unmarshal(e query.Entry) *types.Struct { return details.Details } -func (f *Filters) hasOrders() bool { - return f.Order != nil -} - func (f *Filters) String() string { var filterString string var orderString string diff --git a/pkg/lib/gateway/gateway.go b/pkg/lib/gateway/gateway.go index 02efbeb60..6ece749df 100644 --- a/pkg/lib/gateway/gateway.go +++ b/pkg/lib/gateway/gateway.go @@ -46,10 +46,6 @@ type Gateway interface { app.ComponentStatable } -type spaceIDResolver interface { - ResolveSpaceID(objectID string) (spaceID string, err error) -} - type gateway struct { fileService files.Service fileObjectService fileobject.Service @@ -62,21 +58,6 @@ type gateway struct { limitCh chan struct{} } -func getRandomPort() (int, error) { - addr, err := net.ResolveTCPAddr("tcp", "localhost:0") - if err != nil { - return 0, err - } - - l, err := net.ListenTCP("tcp", addr) - if err != nil { - return 0, err - } - - defer l.Close() - return l.Addr().(*net.TCPAddr).Port, nil -} - func GatewayAddr() string { if addr := os.Getenv("ANYTYPE_GATEWAY_ADDR"); addr != "" { return addr diff --git a/pkg/lib/localstore/ftsearch/ftsearch_test.go b/pkg/lib/localstore/ftsearch/ftsearch_test.go index 2bb7cabdd..564c1786b 100644 --- a/pkg/lib/localstore/ftsearch/ftsearch_test.go +++ b/pkg/lib/localstore/ftsearch/ftsearch_test.go @@ -11,15 +11,13 @@ import ( "github.com/blevesearch/bleve/v2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.uber.org/mock/gomock" "github.com/anyproto/anytype-heart/core/wallet" ) type fixture struct { - ft FTSearch - ta *app.App - ctrl *gomock.Controller + ft FTSearch + ta *app.App } func newFixture(path string, t *testing.T) *fixture { diff --git a/pkg/lib/localstore/objectstore/relations_test.go b/pkg/lib/localstore/objectstore/relations_test.go index 36b404704..76d157d13 100644 --- a/pkg/lib/localstore/objectstore/relations_test.go +++ b/pkg/lib/localstore/objectstore/relations_test.go @@ -8,7 +8,6 @@ import ( "github.com/anyproto/anytype-heart/core/relationutils" "github.com/anyproto/anytype-heart/pkg/lib/bundle" - "github.com/anyproto/anytype-heart/pkg/lib/pb/model" "github.com/anyproto/anytype-heart/util/pbtypes" ) @@ -49,17 +48,6 @@ import ( // }) // } -func makeRelationOptionObject(id, name, color, relationKey string) TestObject { - return TestObject{ - bundle.RelationKeyId: pbtypes.String(id), - bundle.RelationKeyType: pbtypes.String(bundle.TypeKeyRelationOption.URL()), - bundle.RelationKeyName: pbtypes.String(name), - bundle.RelationKeyRelationOptionColor: pbtypes.String(color), - bundle.RelationKeyRelationKey: pbtypes.String(relationKey), - bundle.RelationKeyLayout: pbtypes.Int64(int64(model.ObjectType_relationOption)), - } -} - func TestGetRelationById(t *testing.T) { t.Run("relation is not found", func(t *testing.T) { s := NewStoreFixture(t) diff --git a/space/internal/components/aclnotifications/notifications_test.go b/space/internal/components/aclnotifications/notifications_test.go index f342065c5..05b6ead1e 100644 --- a/space/internal/components/aclnotifications/notifications_test.go +++ b/space/internal/components/aclnotifications/notifications_test.go @@ -644,7 +644,6 @@ func newFixture(t *testing.T) *fixture { type fixture struct { *aclNotificationSender - store *objectstore.StoreFixture notificationSender *mock_aclnotifications.MockNotificationSender identityService *mock_dependencies.MockIdentityService } diff --git a/space/spacecore/localdiscovery/common.go b/space/spacecore/localdiscovery/common.go index edf11bcd1..a7dcb8d49 100644 --- a/space/spacecore/localdiscovery/common.go +++ b/space/spacecore/localdiscovery/common.go @@ -1,10 +1,6 @@ package localdiscovery import ( - "fmt" - "strconv" - "strings" - "github.com/anyproto/any-sync/app" "github.com/anyproto/any-sync/app/logger" ) @@ -37,13 +33,3 @@ type LocalDiscovery interface { Start() error // Start the local discovery. Used when automatic start is disabled. app.ComponentRunnable } - -func getPort(addrs []string) (port int, err error) { - if len(addrs) == 0 { - err = fmt.Errorf("addresses are empty") - return - } - split := strings.Split(addrs[0], ":") - _, portString := split[0], split[1] - return strconv.Atoi(portString) -} diff --git a/space/spacecore/service.go b/space/spacecore/service.go index 9a7298048..911bc6f67 100644 --- a/space/spacecore/service.go +++ b/space/spacecore/service.go @@ -3,8 +3,6 @@ package spacecore import ( "context" "fmt" - "strconv" - "strings" "time" "github.com/anyproto/any-sync/accountservice" @@ -134,12 +132,6 @@ func (s *service) Run(ctx context.Context) (err error) { return } -func parseReplicationKey(spaceID string) (uint64, error) { - parts := strings.Split(spaceID, ".") - raw := parts[len(parts)-1] - return strconv.ParseUint(raw, 36, 64) -} - func (s *service) Derive(ctx context.Context, spaceType string) (space *AnySpace, err error) { payload := commonspace.SpaceDerivePayload{ SigningKey: s.wallet.GetAccountPrivkey(), diff --git a/space/spacecore/streamhandler.go b/space/spacecore/streamhandler.go index a99d1e9c1..fa96ca50e 100644 --- a/space/spacecore/streamhandler.go +++ b/space/spacecore/streamhandler.go @@ -8,7 +8,6 @@ import ( "github.com/anyproto/any-sync/commonspace/objectsync" "github.com/anyproto/any-sync/commonspace/spacesyncproto" "github.com/anyproto/any-sync/net/peer" - "go.uber.org/zap" "golang.org/x/net/context" "storj.io/drpc" ) @@ -81,19 +80,6 @@ func (s *streamHandler) HandleMessage(ctx context.Context, peerId string, msg dr return } -func (s *streamHandler) handleMessage(ctx context.Context, senderId string, req *spacesyncproto.ObjectSyncMessage) (err error) { - var msg = &spacesyncproto.SpaceSubscription{} - if err = msg.Unmarshal(req.Payload); err != nil { - return - } - log.InfoCtx(ctx, "got subscription message", zap.Strings("spaceIds", msg.SpaceIds)) - if msg.Action == spacesyncproto.SpaceSubscriptionAction_Subscribe { - return s.spaceCore.streamPool.AddTagsCtx(ctx, msg.SpaceIds...) - } else { - return s.spaceCore.streamPool.RemoveTagsCtx(ctx, msg.SpaceIds...) - } -} - func (s *streamHandler) NewReadMessage() drpc.Message { // TODO: we can use sync.Pool here return new(spacesyncproto.ObjectSyncMessage)