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/17545

Danielc66018958ecf
diff --git a/kernel/model/file.go b/kernel/model/file.go
index e4b7612264..313ffe01dc 100644
--- a/kernel/model/file.go
+++ b/kernel/model/file.go
@@ -1704,6 +1704,21 @@ func RenameDoc(boxID, p, title string) (err error) {
return
}
+ subFiles := box.ListFiles(tree.Path)
+ for _, subFile := range subFiles {
+ if !strings.HasSuffix(subFile.path, ".sy") {
+ continue
+ }
+
+ subTree, loadErr := filesys.LoadTree(box.ID, subFile.path, luteEngine) // LoadTree 会重新构造 HPath
+ if loadErr != nil {
+ continue
+ }
+
+ treenode.SetBlockTreePath(subTree)
+ sql.RenameTreeQueue(subTree)
+ }
+
refText := getNodeRefText(tree.Root)
evt := util.NewCmdResult("rename", 0, util.PushModeBroadcast)
evt.Data = map[string]any{
diff --git a/kernel/sql/queue.go b/kernel/sql/queue.go
index b68f1b7ac1..b09f295374 100644
--- a/kernel/sql/queue.go
+++ b/kernel/sql/queue.go
@@ -20,7 +20,6 @@ import (
"database/sql"
"errors"
"fmt"
- "math"
"path"
"runtime/debug"
"sync"
@@ -123,30 +122,6 @@ func FlushQueue() {
// logging.LogInfof("flushing database queue, total operations [%d]", total)
- // 如果有重命名子树的操作,则统计各路径前缀的块树数量,数量较大的话阻塞整个队列,以便尽可能合并重命名子树的操作
- var renameSubTreeOp *dbQueueOperation
- for _, op := range ops {
- if "rename_sub_tree" == op.action {
- renameSubTreeOp = op
- break
- }
- }
- if nil != renameSubTreeOp {
- childCount := treenode.CountBlockTreesByPathPrefix(path.Dir(renameSubTreeOp.indexTree.Path))
- if 512 < childCount {
- scale := math.Log(float64(childCount)/512.0+1.0) / math.Log(2.0)
- secs := 1.0 * scale
- if secs < 1.0 {
- secs = 1.0
- }
- if secs > 12.0 {
- secs = 12.0
- }
- logging.LogInfof("rename sub tree [%s] with large child count [%d], sleep [%.2fs] to wait for more operations", renameSubTreeOp.indexTree.Path, childCount, secs)
- time.Sleep(time.Duration(secs * float64(time.Second)))
- }
- }
-
context := map[string]any{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar}
if 512 < len(ops) {
disableCache()