🎨 改进无法读写块树文件后的处理 Fix https://github.com/siyuan-note/siyuan/issues/5619

This commit is contained in:
Liang Ding 2022-08-12 10:43:24 +08:00
parent 18e377f90f
commit b10a7d99f8
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
3 changed files with 2 additions and 41 deletions

View file

@ -40,44 +40,6 @@ import (
"github.com/siyuan-note/siyuan/kernel/util"
)
func (box *Box) BootIndex() {
util.SetBootDetails("Listing files...")
files := box.ListFiles("/")
boxLen := len(Conf.GetOpenedBoxes())
if 1 > boxLen {
boxLen = 1
}
bootProgressPart := 10.0 / float64(boxLen) / float64(len(files))
luteEngine := NewLute()
i := 0
// 读取并缓存路径映射
for _, file := range files {
if file.isdir || !strings.HasSuffix(file.name, ".sy") {
continue
}
p := file.path
tree, err := filesys.LoadTree(box.ID, p, luteEngine)
if nil != err {
logging.LogErrorf("read box [%s] tree [%s] failed: %s", box.ID, p, err)
continue
}
docIAL := parse.IAL2MapUnEsc(tree.Root.KramdownIAL)
cache.PutDocIAL(p, docIAL)
util.IncBootProgress(bootProgressPart, "Parsing tree "+util.ShortPathForBootingDisplay(tree.Path))
// 缓存块树
treenode.IndexBlockTree(tree)
if 1 < i && 0 == i%64 {
filelock.ReleaseAllFileLocks()
}
i++
}
return
}
func (box *Box) Index(fullRebuildIndex bool) (treeCount int, treeSize int64) {
defer debug.FreeOSMemory()