From 7b2d8c8bd094446dcf391ae0316efab706cf25d0 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Tue, 7 May 2024 08:54:31 +0800 Subject: [PATCH] :bug: The new database entry after binding block is lost in some cases https://github.com/siyuan-note/siyuan/issues/11269 --- kernel/model/path.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/kernel/model/path.go b/kernel/model/path.go index e8841f5a0..ee2f51915 100644 --- a/kernel/model/path.go +++ b/kernel/model/path.go @@ -33,13 +33,16 @@ import ( "github.com/siyuan-note/siyuan/kernel/util" ) -func createDocsByHPath(boxID, hPath, content, parentID, id string /* id 参数仅在 parentID 不为空的情况下使用 */) (retID string, err error) { +func createDocsByHPath(boxID, hPath, content, parentID, id string) (retID string, err error) { + if "" == id { + id = ast.NewNodeID() + } + retID = id + hPath = strings.TrimSuffix(hPath, ".sy") if "" != parentID { - retID = id - // The save path is incorrect when creating a sub-doc by ref in a doc with the same name https://github.com/siyuan-note/siyuan/issues/8138 - // 在指定父文档 ID 的情况下优先查找父文档 + // 在指定了父文档 ID 的情况下优先查找父文档 parentHPath, name := path.Split(hPath) parentHPath = strings.TrimSuffix(parentHPath, "/") preferredParent := treenode.GetBlockTreeRootByHPathPreferredParentID(boxID, parentHPath, parentID) @@ -51,11 +54,6 @@ func createDocsByHPath(boxID, hPath, content, parentID, id string /* id 参数 } return } - } else { - retID = ast.NewNodeID() - if "" == id { - id = retID - } } root := treenode.GetBlockTreeRootByPath(boxID, hPath)