♻️ 重构重命名/移动文档路径
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
|
||||
}
|
||||
|
||||
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) {
|
||||
treenode.SetBlockTreePath(tree)
|
||||
sql.UpsertTreeQueue(tree)
|
||||
|
||||
box := Conf.Box(tree.Box)
|
||||
subFiles := box.ListFiles(tree.Path)
|
||||
totals := len(subFiles) + 5
|
||||
showProgress := 64 < totals
|
||||
box.renameSubTrees(tree)
|
||||
}
|
||||
|
||||
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") {
|
||||
continue
|
||||
}
|
||||
|
||||
subTree, err := LoadTree(box.ID, subFile.path)
|
||||
subTree, err := LoadTree(box.ID, subFile.path) // LoadTree 会重新构造 HPath
|
||||
if nil != err {
|
||||
continue
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue