mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 14:40:12 +01:00
⚡ 改进重命名资源文件性能 Fix https://github.com/siyuan-note/siyuan/issues/7322
This commit is contained in:
parent
929a25a783
commit
6743b21193
2 changed files with 12 additions and 5 deletions
|
|
@ -42,6 +42,12 @@ func LoadTree(boxID, p string, luteEngine *lute.Lute) (ret *parse.Tree, err erro
|
|||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
ret, err = LoadTreeByData(data, boxID, p, luteEngine)
|
||||
return
|
||||
}
|
||||
|
||||
func LoadTreeByData(data []byte, boxID, p string, luteEngine *lute.Lute) (ret *parse.Tree, err error) {
|
||||
ret = parseJSON2Tree(boxID, p, data, luteEngine)
|
||||
if nil == ret {
|
||||
return nil, errors.New("parse tree failed")
|
||||
|
|
@ -88,7 +94,7 @@ func LoadTree(boxID, p string, luteEngine *lute.Lute) (ret *parse.Tree, err erro
|
|||
|
||||
ial := ReadDocIAL(parentData)
|
||||
if 1 > len(ial) {
|
||||
logging.LogWarnf("tree [%s] is corrupted", filePath)
|
||||
logging.LogWarnf("tree [%s] is corrupted", filepath.Join(boxID, p))
|
||||
}
|
||||
title := ial["title"]
|
||||
if "" == title {
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ import (
|
|||
"github.com/siyuan-note/httpclient"
|
||||
"github.com/siyuan-note/logging"
|
||||
"github.com/siyuan-note/siyuan/kernel/cache"
|
||||
"github.com/siyuan-note/siyuan/kernel/filesys"
|
||||
"github.com/siyuan-note/siyuan/kernel/search"
|
||||
"github.com/siyuan-note/siyuan/kernel/sql"
|
||||
"github.com/siyuan-note/siyuan/kernel/treenode"
|
||||
|
|
@ -503,6 +504,7 @@ func RenameAsset(oldPath, newName string) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
luteEngine := NewLute()
|
||||
for _, notebook := range notebooks {
|
||||
pages := pagedPaths(filepath.Join(util.DataDir, notebook.ID), 32)
|
||||
|
||||
|
|
@ -528,11 +530,10 @@ func RenameAsset(oldPath, newName string) (err error) {
|
|||
}
|
||||
|
||||
p := filepath.ToSlash(strings.TrimPrefix(treeAbsPath, filepath.Join(util.DataDir, notebook.ID)))
|
||||
tree, parseErr := LoadTree(notebook.ID, p)
|
||||
tree, parseErr := filesys.LoadTreeByData(data, notebook.ID, p, luteEngine)
|
||||
if nil != parseErr {
|
||||
logging.LogErrorf("parse json to tree [%s] failed: %s", treeAbsPath, parseErr)
|
||||
err = parseErr
|
||||
return
|
||||
logging.LogWarnf("parse json to tree [%s] failed: %s", treeAbsPath, parseErr)
|
||||
continue
|
||||
}
|
||||
|
||||
treenode.IndexBlockTree(tree)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue