mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 08:30:42 +02:00
♻️ 重构重命名/移动文档路径
This commit is contained in:
parent
12a78e9682
commit
5f364acbbc
1 changed files with 12 additions and 31 deletions
|
@ -391,47 +391,28 @@ func isSkipFile(filename string) bool {
|
||||||
return strings.HasPrefix(filename, ".") || "node_modules" == filename || "dist" == filename || "target" == filename
|
return strings.HasPrefix(filename, ".") || "node_modules" == filename || "dist" == filename || "target" == filename
|
||||||
}
|
}
|
||||||
|
|
||||||
func (box *Box) renameSubTrees(tree *parse.Tree) {
|
|
||||||
subFiles := box.ListFiles(tree.Path)
|
|
||||||
totals := len(subFiles) + 3
|
|
||||||
showProgress := 64 < totals
|
|
||||||
for i, subFile := range subFiles {
|
|
||||||
if !strings.HasSuffix(subFile.path, ".sy") {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
subTree, err := LoadTree(box.ID, subFile.path) // LoadTree 会重新构造 HPath
|
|
||||||
if nil != err {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
sql.UpsertTreeQueue(subTree)
|
|
||||||
if showProgress {
|
|
||||||
msg := fmt.Sprintf(Conf.Language(107), subTree.HPath)
|
|
||||||
util.PushProgress(util.PushProgressCodeProgressed, i, totals, msg)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if showProgress {
|
|
||||||
util.ClearPushProgress(totals)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func moveTree(tree *parse.Tree) {
|
func moveTree(tree *parse.Tree) {
|
||||||
treenode.SetBlockTreePath(tree)
|
treenode.SetBlockTreePath(tree)
|
||||||
sql.UpsertTreeQueue(tree)
|
sql.UpsertTreeQueue(tree)
|
||||||
|
|
||||||
box := Conf.Box(tree.Box)
|
box := Conf.Box(tree.Box)
|
||||||
subFiles := box.ListFiles(tree.Path)
|
box.renameSubTrees(tree)
|
||||||
totals := len(subFiles) + 5
|
}
|
||||||
showProgress := 64 < totals
|
|
||||||
|
|
||||||
for i, subFile := range subFiles {
|
func (box *Box) renameSubTrees(tree *parse.Tree) {
|
||||||
|
subFiles := box.ListFiles(tree.Path)
|
||||||
|
box.moveTrees0(subFiles)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (box *Box) moveTrees0(files []*FileInfo) {
|
||||||
|
totals := len(files) + 5
|
||||||
|
showProgress := 64 < totals
|
||||||
|
for i, subFile := range files {
|
||||||
if !strings.HasSuffix(subFile.path, ".sy") {
|
if !strings.HasSuffix(subFile.path, ".sy") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
subTree, err := LoadTree(box.ID, subFile.path)
|
subTree, err := LoadTree(box.ID, subFile.path) // LoadTree 会重新构造 HPath
|
||||||
if nil != err {
|
if nil != err {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue