🎨 改进内核任务调度机制提升稳定性 https://github.com/siyuan-note/siyuan/issues/7113

This commit is contained in:
Liang Ding 2023-01-24 15:05:40 +08:00
parent 7e014cb525
commit e7bcf7443b
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
4 changed files with 21 additions and 13 deletions

View file

@ -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