🐛 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
This commit is contained in:
parent
d21b122429
commit
5ad9de9541
2 changed files with 4 additions and 4 deletions
|
@ -45,8 +45,8 @@ func createDocsByHPath(boxID, hPath, content, parentID, id string) (retID string
|
|||
// 在指定了父文档 ID 的情况下优先查找父文档
|
||||
parentHPath, name := path.Split(hPath)
|
||||
parentHPath = strings.TrimSuffix(parentHPath, "/")
|
||||
preferredParent := treenode.GetBlockTreeRootByHPathPreferredParentID(boxID, parentHPath, parentID)
|
||||
if nil != preferredParent && preferredParent.ID == parentID {
|
||||
preferredParent := treenode.GetBlockTreeByHPathPreferredParentID(boxID, parentHPath, parentID)
|
||||
if nil != preferredParent && preferredParent.RootID == parentID {
|
||||
// 如果父文档存在且 ID 一致,则直接在父文档下创建
|
||||
p := strings.TrimSuffix(preferredParent.Path, ".sy") + "/" + id + ".sy"
|
||||
if _, err = createDoc(boxID, p, name, content); err != nil {
|
||||
|
|
|
@ -258,10 +258,10 @@ func GetBlockTreeRootsByHPath(boxID, hPath string) (ret []*BlockTree) {
|
|||
return
|
||||
}
|
||||
|
||||
func GetBlockTreeRootByHPathPreferredParentID(boxID, hPath, preferredParentID string) (ret *BlockTree) {
|
||||
func GetBlockTreeByHPathPreferredParentID(boxID, hPath, preferredParentID string) (ret *BlockTree) {
|
||||
hPath = gulu.Str.RemoveInvisible(hPath)
|
||||
var roots []*BlockTree
|
||||
sqlStmt := "SELECT * FROM blocktrees WHERE box_id = ? AND hpath = ? AND parent_id = ? AND type = 'd'"
|
||||
sqlStmt := "SELECT * FROM blocktrees WHERE box_id = ? AND hpath = ? AND parent_id = ? LIMIT 1"
|
||||
rows, err := db.Query(sqlStmt, boxID, hPath, preferredParentID)
|
||||
if err != nil {
|
||||
logging.LogErrorf("sql query [%s] failed: %s", sqlStmt, err)
|
||||
|
|
Loading…
Add table
Reference in a new issue