An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: 改进内核任务调度机制提升稳定性 https://github.com/siyuan-note/siyuan/issues/7113
Liang Ding6141be700a04
diff --git a/kernel/model/box.go b/kernel/model/box.goindex 64caaf5c90..da1b573070 100644--- a/kernel/model/box.go+++ b/kernel/model/box.go@@ -339,22 +339,6 @@ func (box *Box) Remove(path string) error {return nil}-func (box *Box) Unindex() {- task.PrependTask(task.DatabaseIndex, unindex, box.ID)-}--func unindex(boxID string) {- tx, err := sql.BeginTx()- if nil != err {- return- }- sql.RemoveBoxHash(tx, boxID)- sql.DeleteByBoxTx(tx, boxID)- sql.CommitTx(tx)- ids := treenode.RemoveBlockTreesByBoxID(boxID)- RemoveRecentDoc(ids)-}-func (box *Box) ListFiles(path string) (ret []*FileInfo) {fis, _, err := box.Ls(path)if nil != err {@@ -512,7 +496,7 @@ func fullReindex() {openedBoxes := Conf.GetOpenedBoxes()for _, openedBox := range openedBoxes {- openedBox.Index(true)+ index(openedBox.ID, true)}IndexRefs()treenode.SaveBlockTree(true)diff --git a/kernel/model/conf.go b/kernel/model/conf.goindex 3648213379..2af166b92a 100644--- a/kernel/model/conf.go+++ b/kernel/model/conf.go@@ -599,7 +599,7 @@ func InitBoxes() {box.UpdateHistoryGenerated() // 初始化历史生成时间为当前时间if !initialized {- box.Index(true)+ index(box.ID, true)}}diff --git a/kernel/model/index.go b/kernel/model/index.goindex 55b7995ba7..cb7cb53877 100644--- a/kernel/model/index.go+++ b/kernel/model/index.go@@ -20,6 +20,7 @@ import ("bytes""crypto/sha256""fmt"+ "github.com/siyuan-note/siyuan/kernel/task""runtime/debug""sort""strings"@@ -37,7 +38,32 @@ import ("github.com/siyuan-note/siyuan/kernel/util")-func (box *Box) Index(fullRebuildIndex bool) (treeCount int, treeSize int64) {+func (box *Box) Unindex() {+ task.PrependTask(task.DatabaseIndex, unindex, box.ID)+}++func unindex(boxID string) {+ tx, err := sql.BeginTx()+ if nil != err {+ return+ }+ sql.RemoveBoxHash(tx, boxID)+ sql.DeleteByBoxTx(tx, boxID)+ sql.CommitTx(tx)+ ids := treenode.RemoveBlockTreesByBoxID(boxID)+ RemoveRecentDoc(ids)+}++func (box *Box) Index(fullRebuildIndex bool) {+ task.PrependTask(task.DatabaseIndex, index, box.ID, fullRebuildIndex)+}++func index(boxID string, fullRebuildIndex bool) {+ box := Conf.Box(boxID)+ if nil == box {+ return+ }+defer debug.FreeOSMemory()sql.IndexMode()@@ -59,7 +85,8 @@ func (box *Box) Index(fullRebuildIndex bool) (treeCount int, treeSize int64) {luteEngine := NewLute()idTitleMap := map[string]string{}idHashMap := map[string]string{}-+ var treeCount int+ var treeSize int64util.PushEndlessProgress(fmt.Sprintf("["+box.Name+"] "+Conf.Language(64), len(files)))i := 0