mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-11 09:44:21 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
5c21de0a0c
2 changed files with 7 additions and 8 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,16 +69,13 @@ 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))
|
||||
ret := &parse.Tree{Root: root}
|
||||
ret.Box = boxID
|
||||
ret.Path = p
|
||||
ret.HPath = hp
|
||||
ret := &parse.Tree{Root: root, ID: id, Box: boxID, Path: p, 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
Add a link
Reference in a new issue