改进重命名资源文件性能 Fix https://github.com/siyuan-note/siyuan/issues/7322

This commit is contained in:
Liang Ding 2023-02-10 12:05:56 +08:00
parent 929a25a783
commit 6743b21193
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 12 additions and 5 deletions

View file

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