From 7074aacaccd836fc74a1043baeed0e343df1f427 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Tue, 28 Feb 2023 17:43:54 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E5=AF=BC=E5=85=A5=20Markdown=20?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A4=B9=E5=90=8E=E6=97=A0=E6=B3=95=E5=9C=A8?= =?UTF-8?q?=E5=85=B6=E4=B8=AD=E7=BB=A7=E7=BB=AD=E5=AF=BC=E5=85=A5=20https:?= =?UTF-8?q?//github.com/siyuan-note/siyuan/issues/7512?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/import.go | 6 ++++-- kernel/treenode/tree.go | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/kernel/model/import.go b/kernel/model/import.go index ac67b8ce0..ad1c4234d 100644 --- a/kernel/model/import.go +++ b/kernel/model/import.go @@ -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 { diff --git a/kernel/treenode/tree.go b/kernel/treenode/tree.go index 27c9b2bf1..b2d1549bc 100644 --- a/kernel/treenode/tree.go +++ b/kernel/treenode/tree.go @@ -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)