🐛 Failed to rename the document after moving it https://github.com/siyuan-note/siyuan/issues/11661
This commit is contained in:
parent
0de9ecb61b
commit
1b7be9b6f0
2 changed files with 25 additions and 5 deletions
|
@ -404,12 +404,9 @@ func moveTree(tree *parse.Tree) {
|
|||
|
||||
func (box *Box) renameSubTrees(tree *parse.Tree) {
|
||||
subFiles := box.ListFiles(tree.Path)
|
||||
box.moveTrees0(subFiles)
|
||||
}
|
||||
|
||||
func (box *Box) moveTrees0(files []*FileInfo) {
|
||||
luteEngine := util.NewLute()
|
||||
for _, subFile := range files {
|
||||
for _, subFile := range subFiles {
|
||||
if !strings.HasSuffix(subFile.path, ".sy") {
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -1477,7 +1477,8 @@ func moveDoc(fromBox *Box, fromPath string, toBox *Box, toPath string, luteEngin
|
|||
}
|
||||
}
|
||||
|
||||
if fromBox.Exist(fromFolder) {
|
||||
needMoveSubDocs := fromBox.Exist(fromFolder)
|
||||
if needMoveSubDocs {
|
||||
// 移动子文档文件夹
|
||||
|
||||
newFolder := path.Join(toFolder, tree.ID)
|
||||
|
@ -1532,6 +1533,28 @@ func moveDoc(fromBox *Box, fromPath string, toBox *Box, toPath string, luteEngin
|
|||
moveSorts(tree.ID, fromBox.ID, toBox.ID)
|
||||
}
|
||||
|
||||
if needMoveSubDocs {
|
||||
// 将其所有子文档的移动事件推送到前端 https://github.com/siyuan-note/siyuan/issues/11661
|
||||
subDocsFolder := path.Join(toFolder, tree.ID)
|
||||
syFiles := listSyFiles(path.Join(toBox.ID, subDocsFolder))
|
||||
for _, syFile := range syFiles {
|
||||
relPath := strings.TrimPrefix(syFile, "/"+path.Join(toBox.ID, toFolder))
|
||||
subFromPath := path.Join(path.Dir(fromPath), relPath)
|
||||
subToPath := path.Join(toFolder, relPath)
|
||||
|
||||
evt := util.NewCmdResult("moveDoc", 0, util.PushModeBroadcast)
|
||||
evt.Data = map[string]interface{}{
|
||||
"fromNotebook": fromBox.ID,
|
||||
"fromPath": subFromPath,
|
||||
"toNotebook": toBox.ID,
|
||||
"toPath": path.Dir(subToPath) + ".sy",
|
||||
"newPath": subToPath,
|
||||
}
|
||||
evt.Callback = callback
|
||||
util.PushEvent(evt)
|
||||
}
|
||||
}
|
||||
|
||||
evt := util.NewCmdResult("moveDoc", 0, util.PushModeBroadcast)
|
||||
evt.Data = map[string]interface{}{
|
||||
"fromNotebook": fromBox.ID,
|
||||
|
|
Loading…
Add table
Reference in a new issue