From f59add1e61f89d7a1cb2cda6a0ce42db8cf9d064 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Sun, 5 Feb 2023 18:01:33 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E6=96=87=E6=A1=A3=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E6=A0=87=E9=A2=98=E8=A7=A6=E5=8F=91=E7=8A=B6=E6=80=81=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/heading.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/kernel/model/heading.go b/kernel/model/heading.go index 27321db13..208687dcf 100644 --- a/kernel/model/heading.go +++ b/kernel/model/heading.go @@ -26,6 +26,7 @@ import ( "github.com/88250/gulu" "github.com/88250/lute/ast" "github.com/88250/lute/parse" + "github.com/siyuan-note/logging" "github.com/siyuan-note/siyuan/kernel/cache" "github.com/siyuan-note/siyuan/kernel/sql" "github.com/siyuan-note/siyuan/kernel/treenode" @@ -118,7 +119,9 @@ func Doc2Heading(srcID, targetID string, after bool) (srcTreeBox, srcTreePath st return } - os.Remove(subDir) // 移除空文件夹不会有副作用 + if removeErr := os.Remove(subDir); nil != removeErr { // 移除空文件夹不会有副作用 + logging.LogWarnf("remove empty dir [%s] failed: %s", subDir, removeErr) + } } targetTree, _ := loadTreeByBlockID(targetID) @@ -160,9 +163,9 @@ func Doc2Heading(srcID, targetID string, after bool) (srcTreeBox, srcTreePath st tags := strings.Split(tagIAL, ",") srcTree.Root.RemoveIALAttr("tags") heading := &ast.Node{ID: srcTree.Root.ID, Type: ast.NodeHeading, HeadingLevel: headingLevel, KramdownIAL: srcTree.Root.KramdownIAL} + heading.SetIALAttr("updated", util.CurrentTimeSecondsStr()) heading.AppendChild(&ast.Node{Type: ast.NodeText, Tokens: []byte(srcTree.Root.IALAttr("title"))}) - heading.Box = targetTree.Box - heading.Path = targetTree.Path + heading.Box, heading.Path = targetTree.Box, targetTree.Path if "" != tagIAL && 0 < len(tags) { // 带标签的文档块转换为标题块时将标签移动到标题块下方 https://github.com/siyuan-note/siyuan/issues/6550 @@ -221,12 +224,7 @@ func Doc2Heading(srcID, targetID string, after bool) (srcTreeBox, srcTreePath st contentPivot.Unlink() } - srcTreeBox, srcTreePath = srcTree.Box, srcTree.Path - srcTree.Root.SetIALAttr("updated", util.CurrentTimeSecondsStr()) - if err = indexWriteJSONQueue(srcTree); nil != err { - return - } - + srcTreeBox, srcTreePath = srcTree.Box, srcTree.Path // 返回旧的文档块位置,前端后续会删除旧的文档块 targetTree.Root.SetIALAttr("updated", util.CurrentTimeSecondsStr()) err = indexWriteJSONQueue(targetTree) IncSync()