Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/17564

Danielcd5761088bbc
diff --git a/kernel/model/file.go b/kernel/model/file.go
index 55c4e0abf8..25913c355b 100644
--- a/kernel/model/file.go
+++ b/kernel/model/file.go
@@ -1212,12 +1212,12 @@ func GetHPathByPath(boxID, p string) (hPath string, err error) {
return
}
- luteEngine := util.NewLute()
- tree, err := filesys.LoadTree(boxID, p, luteEngine)
- if err != nil {
+ bt := treenode.GetBlockTreeByBoxPath(boxID, p)
+ if nil == bt {
+ err = ErrBlockNotFound
return
}
- hPath = tree.HPath
+ hPath = bt.HPath
return
}
@@ -1229,7 +1229,7 @@ func GetHPathsByPaths(paths []string) (hPaths []string, err error) {
continue
}
- bt := treenode.GetBlockTreeByPath(p)
+ bt := treenode.GetBlockTreeByBoxPath(box.ID, p)
if nil == bt {
logging.LogWarnf("block tree not found by path [%s]", p)
continue
diff --git a/kernel/treenode/blocktree.go b/kernel/treenode/blocktree.go
index 4b31314518..0814650132 100644
--- a/kernel/treenode/blocktree.go
+++ b/kernel/treenode/blocktree.go
@@ -153,10 +153,10 @@ func GetBlockTreesByType(typ string) (ret []*BlockTree) {
return
}
-func GetBlockTreeByPath(path string) (ret *BlockTree) {
+func GetBlockTreeByBoxPath(boxID, path string) (ret *BlockTree) {
ret = &BlockTree{}
- sqlStmt := "SELECT * FROM blocktrees WHERE path = ?"
- err := queryRow(sqlStmt, path).Scan(&ret.ID, &ret.RootID, &ret.ParentID, &ret.BoxID, &ret.Path, &ret.HPath, &ret.Updated, &ret.Type)
+ sqlStmt := "SELECT * FROM blocktrees WHERE box_id = ? AND path = ?"
+ err := queryRow(sqlStmt, boxID, path).Scan(&ret.ID, &ret.RootID, &ret.ParentID, &ret.BoxID, &ret.Path, &ret.HPath, &ret.Updated, &ret.Type)
if err != nil {
ret = nil
if errors.Is(err, sql.ErrNoRows) {