Jelajahi Sumber

:art: Improve kernel stability https://github.com/siyuan-note/siyuan/issues/9912

Daniel 1 tahun lalu
induk
melakukan
ad6edcae03
1 mengubah file dengan 7 tambahan dan 8 penghapusan
  1. 7 8
      kernel/model/path.go

+ 7 - 8
kernel/model/path.go

@@ -52,9 +52,9 @@ func createDocsByHPath(boxID, hPath, content, parentID, id string /* id 参数
 			return
 		}
 	} else {
+		retID = ast.NewNodeID()
 		if "" == id {
-			id = ast.NewNodeID()
-			retID = id
+			id = retID
 		}
 	}
 
@@ -95,10 +95,12 @@ func createDocsByHPath(boxID, hPath, content, parentID, id string /* id 参数
 		root = hpathBtMap[hp]
 		isNotLast := i < len(parts)-1
 		if nil == root {
-			if "" == retID {
-				retID = ast.NewNodeID()
+			rootID := ast.NewNodeID()
+			if i == len(parts)-1 {
+				rootID = retID
 			}
-			pathBuilder.WriteString(retID)
+
+			pathBuilder.WriteString(rootID)
 			docP := pathBuilder.String() + ".sy"
 			if isNotLast {
 				if _, err = createDoc(boxID, docP, part, ""); nil != err {
@@ -118,9 +120,6 @@ func createDocsByHPath(boxID, hPath, content, parentID, id string /* id 参数
 				}
 			}
 		} else {
-			if "" == retID {
-				retID = root.ID
-			}
 			pathBuilder.WriteString(root.ID)
 			if !isNotLast {
 				pathBuilder.WriteString(".sy")