🐛 导入 Markdown 文件夹后无法在其中继续导入 https://github.com/siyuan-note/siyuan/issues/7512
This commit is contained in:
parent
e772e97b72
commit
7074aacacc
2 changed files with 6 additions and 4 deletions
|
@ -509,8 +509,11 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {
|
|||
|
||||
curRelPath := filepath.ToSlash(strings.TrimPrefix(currentPath, localPath))
|
||||
targetPath := path.Join(baseTargetPath, id)
|
||||
hPath := path.Join(baseHPath, filepath.ToSlash(strings.TrimPrefix(currentPath, localPath)))
|
||||
hPath = strings.TrimSuffix(hPath, ext)
|
||||
if "" == curRelPath {
|
||||
curRelPath = "/"
|
||||
hPath = "/" + title
|
||||
} else {
|
||||
dirPath := targetPaths[path.Dir(curRelPath)]
|
||||
targetPath = path.Join(dirPath, id)
|
||||
|
@ -519,8 +522,7 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {
|
|||
targetPath = strings.ReplaceAll(targetPath, ".sy/", "/")
|
||||
targetPath += ".sy"
|
||||
targetPaths[curRelPath] = targetPath
|
||||
hPath := path.Join(baseHPath, filepath.ToSlash(strings.TrimPrefix(currentPath, localPath)))
|
||||
hPath = strings.TrimSuffix(hPath, ext)
|
||||
|
||||
if info.IsDir() {
|
||||
tree = treenode.NewTree(boxID, targetPath, hPath, title)
|
||||
if err = indexWriteJSONQueue(tree); nil != err {
|
||||
|
|
|
@ -69,7 +69,7 @@ func TreeRoot(node *ast.Node) *ast.Node {
|
|||
|
||||
func NewTree(boxID, p, hp, title string) *parse.Tree {
|
||||
id := strings.TrimSuffix(path.Base(p), ".sy")
|
||||
root := &ast.Node{Type: ast.NodeDocument, ID: id}
|
||||
root := &ast.Node{Type: ast.NodeDocument, ID: id, Spec: "1", Box: boxID, Path: p}
|
||||
root.SetIALAttr("title", title)
|
||||
root.SetIALAttr("id", id)
|
||||
root.SetIALAttr("updated", util.TimeFromID(id))
|
||||
|
@ -78,7 +78,7 @@ func NewTree(boxID, p, hp, title string) *parse.Tree {
|
|||
ret.Path = p
|
||||
ret.HPath = hp
|
||||
ret.Root.Spec = "1"
|
||||
newPara := &ast.Node{Type: ast.NodeParagraph, ID: ast.NewNodeID()}
|
||||
newPara := &ast.Node{Type: ast.NodeParagraph, ID: ast.NewNodeID(), Box: boxID, Path: p}
|
||||
newPara.SetIALAttr("id", newPara.ID)
|
||||
newPara.SetIALAttr("updated", util.TimeFromID(newPara.ID))
|
||||
ret.Root.AppendChild(newPara)
|
||||
|
|
Loading…
Add table
Reference in a new issue