mirror of
https://github.com/anyproto/anytype-heart.git
synced 2025-06-11 18:20:33 +09:00
GO-5344 Merge branch 'main' of github.com:anyproto/anytype-heart into go-5344-add-mention-counters
This commit is contained in:
commit
eaf340ece0
95 changed files with 13527 additions and 22824 deletions
|
@ -9,7 +9,7 @@ import (
|
|||
"github.com/anyproto/anytype-heart/pkg/lib/pb/model"
|
||||
)
|
||||
|
||||
const RelationChecksum = "e8392d6bf8efab6b707d68bc3922e4284a18a68370828e3ec6b18e0267b84bea"
|
||||
const RelationChecksum = "a23583f8faef1cbfcd05ca1d2761538e67bbdd1336d1a467a0d657b5f986b313"
|
||||
const (
|
||||
RelationKeyTag domain.RelationKey = "tag"
|
||||
RelationKeyCamera domain.RelationKey = "camera"
|
||||
|
@ -158,6 +158,7 @@ const (
|
|||
RelationKeyDefaultViewType domain.RelationKey = "defaultViewType"
|
||||
RelationKeyDefaultTypeId domain.RelationKey = "defaultTypeId"
|
||||
RelationKeyAutoWidgetTargets domain.RelationKey = "autoWidgetTargets"
|
||||
RelationKeyAutoWidgetDisabled domain.RelationKey = "autoWidgetDisabled"
|
||||
RelationKeyPluralName domain.RelationKey = "pluralName"
|
||||
)
|
||||
|
||||
|
@ -282,6 +283,19 @@ var (
|
|||
Revision: 1,
|
||||
Scope: model.Relation_type,
|
||||
},
|
||||
RelationKeyAutoWidgetDisabled: {
|
||||
|
||||
DataSource: model.Relation_details,
|
||||
Description: "",
|
||||
Format: model.RelationFormat_checkbox,
|
||||
Hidden: true,
|
||||
Id: "_brautoWidgetDisabled",
|
||||
Key: "autoWidgetDisabled",
|
||||
Name: "Auto Widget disabled",
|
||||
ReadOnly: false,
|
||||
ReadOnlyRelation: true,
|
||||
Scope: model.Relation_type,
|
||||
},
|
||||
RelationKeyAutoWidgetTargets: {
|
||||
|
||||
DataSource: model.Relation_details,
|
||||
|
|
|
@ -1517,6 +1517,15 @@
|
|||
"readonly": false,
|
||||
"source": "details"
|
||||
},
|
||||
{
|
||||
"format": "checkbox",
|
||||
"hidden": true,
|
||||
"key": "autoWidgetDisabled",
|
||||
"maxCount": 0,
|
||||
"name": "Auto Widget disabled",
|
||||
"readonly": false,
|
||||
"source": "details"
|
||||
},
|
||||
{
|
||||
"description": "Name of Object type in plural form",
|
||||
"format": "longtext",
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"github.com/anyproto/anytype-heart/pkg/lib/pb/model"
|
||||
)
|
||||
|
||||
const TypeChecksum = "91c804ca7dd4df74fafbdaff99e50fa2ffcc6cb0fb073887a90bdf1b4a3d98d5"
|
||||
const TypeChecksum = "f2672b9f52915f228e335b78ed94ce1b6c7b195ceb1cba9a44b25a870a3b2ac0"
|
||||
const (
|
||||
TypePrefix = "_ot"
|
||||
)
|
||||
|
@ -426,7 +426,7 @@ var (
|
|||
Name: "Task",
|
||||
PluralName: "Tasks",
|
||||
Readonly: true,
|
||||
RelationLinks: []*model.RelationLink{MustGetRelationLink(RelationKeyTag), MustGetRelationLink(RelationKeyAssignee), MustGetRelationLink(RelationKeyDone), MustGetRelationLink(RelationKeyDueDate), MustGetRelationLink(RelationKeyLinkedProjects), MustGetRelationLink(RelationKeyPriority), MustGetRelationLink(RelationKeyStatus), MustGetRelationLink(RelationKeyTasks)},
|
||||
RelationLinks: []*model.RelationLink{MustGetRelationLink(RelationKeyTag), MustGetRelationLink(RelationKeyAssignee), MustGetRelationLink(RelationKeyDone), MustGetRelationLink(RelationKeyDueDate), MustGetRelationLink(RelationKeyLinkedProjects), MustGetRelationLink(RelationKeyStatus)},
|
||||
Revision: 2,
|
||||
Types: []model.SmartBlockType{model.SmartBlockType_Page},
|
||||
Url: TypePrefix + "task",
|
||||
|
|
|
@ -107,9 +107,7 @@
|
|||
"done",
|
||||
"dueDate",
|
||||
"linkedProjects",
|
||||
"priority",
|
||||
"status",
|
||||
"tasks"
|
||||
"status"
|
||||
],
|
||||
"description": "A piece of work to be done or undertaken",
|
||||
"revision": 2
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/anyproto/any-sync/app"
|
||||
|
||||
|
@ -54,8 +55,36 @@ func (s *TempDirService) TempDir() string {
|
|||
s.tempDir = os.TempDir()
|
||||
} else {
|
||||
s.tempDir = path
|
||||
go s.cleanUp()
|
||||
}
|
||||
})
|
||||
|
||||
return s.tempDir
|
||||
}
|
||||
|
||||
func (s *TempDirService) cleanUp() {
|
||||
cutoff := time.Now().Add(-72 * time.Hour)
|
||||
recursiveCleanup(s.tempDir, cutoff)
|
||||
}
|
||||
|
||||
func recursiveCleanup(path string, cutoff time.Time) {
|
||||
entries, err := os.ReadDir(path)
|
||||
if err != nil {
|
||||
log.Warnf("tmp cleanup readdir: %v", err)
|
||||
}
|
||||
for _, entry := range entries {
|
||||
fullEntryPath := filepath.Join(path, entry.Name())
|
||||
info, err := entry.Info()
|
||||
if err != nil {
|
||||
log.Warnf("tmp cleanup entry: %v", err)
|
||||
}
|
||||
if entry.IsDir() {
|
||||
recursiveCleanup(fullEntryPath, cutoff)
|
||||
} else if info.ModTime().IsZero() || info.ModTime().Before(cutoff) {
|
||||
err = os.RemoveAll(fullEntryPath)
|
||||
if err != nil {
|
||||
log.Warnf("tmp cleanup delete: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
50
pkg/lib/core/tmp_dir_test.go
Normal file
50
pkg/lib/core/tmp_dir_test.go
Normal file
|
@ -0,0 +1,50 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestTempDirService(t *testing.T) {
|
||||
t.Run("cleanup", func(t *testing.T) {
|
||||
// given
|
||||
s := NewTempDirService()
|
||||
s.tempDir = t.TempDir()
|
||||
|
||||
oldFile := filepath.Join(s.tempDir, "old.txt")
|
||||
require.NoError(t, os.WriteFile(oldFile, []byte("old"), 0600))
|
||||
oldTime := time.Now().Add(-100 * time.Hour)
|
||||
require.NoError(t, os.Chtimes(oldFile, oldTime, oldTime))
|
||||
|
||||
newFile := filepath.Join(s.tempDir, "new.txt")
|
||||
require.NoError(t, os.WriteFile(newFile, []byte("new"), 0600))
|
||||
|
||||
nestedDir := filepath.Join(s.tempDir, "nested")
|
||||
require.NoError(t, os.MkdirAll(nestedDir, 0755))
|
||||
nestedOldFile := filepath.Join(nestedDir, "nested_old.txt")
|
||||
require.NoError(t, os.WriteFile(nestedOldFile, []byte("nested old"), 0600))
|
||||
require.NoError(t, os.Chtimes(nestedOldFile, oldTime, oldTime))
|
||||
nestedNewFile := filepath.Join(nestedDir, "nested_new.txt")
|
||||
require.NoError(t, os.WriteFile(nestedNewFile, []byte("nested new"), 0600))
|
||||
|
||||
// when
|
||||
s.cleanUp()
|
||||
|
||||
// then
|
||||
_, err := os.Stat(oldFile)
|
||||
require.True(t, os.IsNotExist(err), "old file should be deleted")
|
||||
|
||||
_, err = os.Stat(newFile)
|
||||
require.NoError(t, err, "new file should remain")
|
||||
|
||||
_, err = os.Stat(nestedOldFile)
|
||||
require.True(t, os.IsNotExist(err), "nested old file should be deleted")
|
||||
|
||||
_, err = os.Stat(nestedNewFile)
|
||||
require.NoError(t, err, "nested new file should remain")
|
||||
})
|
||||
}
|
|
@ -25,6 +25,7 @@ import (
|
|||
"unicode"
|
||||
|
||||
"github.com/anyproto/any-sync/app"
|
||||
"github.com/anyproto/any-sync/app/debugstat"
|
||||
tantivy "github.com/anyproto/tantivy-go"
|
||||
"github.com/valyala/fastjson"
|
||||
|
||||
|
@ -102,6 +103,19 @@ type ftSearch struct {
|
|||
lang tantivy.Language
|
||||
}
|
||||
|
||||
func (f *ftSearch) ProvideStat() any {
|
||||
count, _ := f.DocCount()
|
||||
return count
|
||||
}
|
||||
|
||||
func (f *ftSearch) StatId() string {
|
||||
return "doc_count"
|
||||
}
|
||||
|
||||
func (f *ftSearch) StatType() string {
|
||||
return CName
|
||||
}
|
||||
|
||||
func TantivyNew() FTSearch {
|
||||
return new(ftSearch)
|
||||
}
|
||||
|
@ -138,6 +152,10 @@ func (f *ftSearch) DeleteObject(objectId string) error {
|
|||
|
||||
func (f *ftSearch) Init(a *app.App) error {
|
||||
repoPath := app.MustComponent[wallet.Wallet](a).RepoPath()
|
||||
statService, _ := app.GetComponent[debugstat.StatService](a)
|
||||
if statService != nil {
|
||||
statService.AddProvider(f)
|
||||
}
|
||||
f.lang = validateLanguage(app.MustComponent[wallet.Wallet](a).FtsPrimaryLang())
|
||||
f.rootPath = filepath.Join(repoPath, ftsDir2)
|
||||
f.blevePath = filepath.Join(repoPath, ftsDir)
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
anystore "github.com/anyproto/any-store"
|
||||
"github.com/anyproto/any-store/anyenc"
|
||||
"github.com/anyproto/any-sync/app"
|
||||
"github.com/anyproto/any-sync/app/debugstat"
|
||||
"github.com/anyproto/any-sync/coordinator/coordinatorproto"
|
||||
"golang.org/x/exp/maps"
|
||||
|
||||
|
@ -124,6 +125,19 @@ type dsObjectStore struct {
|
|||
componentCtxCancel context.CancelFunc
|
||||
}
|
||||
|
||||
func (s *dsObjectStore) ProvideStat() any {
|
||||
count, _ := s.ListIdsCrossSpace()
|
||||
return len(count)
|
||||
}
|
||||
|
||||
func (s *dsObjectStore) StatId() string {
|
||||
return "ds_count"
|
||||
}
|
||||
|
||||
func (s *dsObjectStore) StatType() string {
|
||||
return CName
|
||||
}
|
||||
|
||||
func (s *dsObjectStore) IterateSpaceIndex(f func(store spaceindex.Store) error) error {
|
||||
s.Lock()
|
||||
spaceIndexes := make([]spaceindex.Store, 0, len(s.spaceIndexes))
|
||||
|
@ -169,6 +183,10 @@ func (s *dsObjectStore) Init(a *app.App) (err error) {
|
|||
s.setDefaultConfig()
|
||||
s.oldStore = app.MustComponent[oldstore.Service](a)
|
||||
s.techSpaceIdProvider = app.MustComponent[TechSpaceIdProvider](a)
|
||||
statService, _ := app.GetComponent[debugstat.StatService](a)
|
||||
if statService != nil {
|
||||
statService.AddProvider(s)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -42,6 +42,14 @@ const (
|
|||
TIFF Format = "tiff"
|
||||
)
|
||||
|
||||
func IsImageExt(ext string) bool {
|
||||
switch strings.ToLower(strings.TrimPrefix(ext, ".")) {
|
||||
case "jpg", "jpeg", "png", "gif", "ico", "webp", "heic", "heif", "bmp", "tiff", "psd":
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func IsImage(mime string) bool {
|
||||
parts := strings.SplitN(mime, "/", 2)
|
||||
if len(parts) == 1 {
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -593,6 +593,7 @@ message Block {
|
|||
Layout layout = 1;
|
||||
int32 limit = 2;
|
||||
string viewId = 3;
|
||||
bool autoAdded = 4;
|
||||
|
||||
enum Layout {
|
||||
Link = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue