mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 11:50:04 -06:00
🎨 改进内核任务调度机制提升稳定性 https://github.com/siyuan-note/siyuan/issues/7113
This commit is contained in:
@@ -391,6 +391,8 @@ func getBlock(id string) (ret *Block, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
waitForIndexing()
|
||||
|
||||
tree, err := loadTreeByBlockID(id)
|
||||
if nil != err {
|
||||
return
|
||||
|
||||
@@ -49,12 +49,25 @@ func (box *Box) Index() {
|
||||
task.AppendTask(task.DatabaseIndexRef, IndexRefs)
|
||||
}
|
||||
|
||||
var indexing = false
|
||||
|
||||
func waitForIndexing() {
|
||||
for indexing {
|
||||
time.Sleep(time.Millisecond * 100)
|
||||
}
|
||||
}
|
||||
|
||||
func index(boxID string) {
|
||||
box := Conf.Box(boxID)
|
||||
if nil == box {
|
||||
return
|
||||
}
|
||||
|
||||
indexing = true
|
||||
defer func() {
|
||||
indexing = false
|
||||
}()
|
||||
|
||||
util.SetBootDetails("Listing files...")
|
||||
files := box.ListFiles("/")
|
||||
boxLen := len(Conf.GetOpenedBoxes())
|
||||
@@ -68,9 +81,7 @@ func index(boxID string) {
|
||||
var treeCount int
|
||||
var treeSize int64
|
||||
i := 0
|
||||
|
||||
util.PushStatusBar(fmt.Sprintf("["+box.Name+"] "+Conf.Language(64), len(files)))
|
||||
|
||||
for _, file := range files {
|
||||
if file.isdir || !strings.HasSuffix(file.name, ".sy") {
|
||||
continue
|
||||
|
||||
@@ -1306,6 +1306,12 @@ func autoFixIndex() {
|
||||
}
|
||||
}
|
||||
|
||||
// 清理已关闭的笔记本块树
|
||||
boxes = Conf.GetClosedBoxes()
|
||||
for _, box := range boxes {
|
||||
treenode.RemoveBlockTreesByBoxID(box.ID)
|
||||
}
|
||||
|
||||
// 对比块树和数据库并订正数据库
|
||||
rootUpdatedMap := treenode.GetRootUpdated()
|
||||
dbRootUpdatedMap, err := sql.GetRootUpdated("blocks")
|
||||
|
||||
@@ -292,17 +292,6 @@ func ReindexBlockTree(tree *parse.Tree) {
|
||||
blockTreesLock.Lock()
|
||||
defer blockTreesLock.Unlock()
|
||||
|
||||
//var ids []string
|
||||
//for _, b := range blockTrees {
|
||||
// if b.RootID == tree.ID {
|
||||
// ids = append(ids, b.ID)
|
||||
// }
|
||||
//}
|
||||
//ids = gulu.Str.RemoveDuplicatedElem(ids)
|
||||
//for _, id := range ids {
|
||||
// delete(blockTrees, id)
|
||||
//}
|
||||
|
||||
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||
if !entering || !n.IsBlock() {
|
||||
return ast.WalkContinue
|
||||
|
||||
Reference in New Issue
Block a user