Skip to content

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

:art: Improve document tree custom sorting stability when creating a notebook or doc https://github.com/siyuan-note/siyuan/issues/15716

Daniel6c1156afc887
diff --git a/kernel/model/file.go b/kernel/model/file.go
index 51dbaf4e3c..fb9b77265c 100644
--- a/kernel/model/file.go
+++ b/kernel/model/file.go
@@ -1024,7 +1024,11 @@ func CreateDocByMd(boxID, p, title, md string, sorts []string) (tree *parse.Tree
}
FlushTxQueue()
- ChangeFileTreeSort(box.ID, sorts)
+ if 0 < len(sorts) {
+ ChangeFileTreeSort(box.ID, sorts)
+ } else {
+ box.addMinSort(path.Dir(tree.Path), tree.ID)
+ }
return
}
diff --git a/kernel/model/mount.go b/kernel/model/mount.go
index 41eabccd1d..232ba93768 100644
--- a/kernel/model/mount.go
+++ b/kernel/model/mount.go
@@ -50,6 +50,13 @@ func CreateBox(name string) (id string, err error) {
createDocLock.Lock()
defer createDocLock.Unlock()
+ boxes, _ := ListNotebooks()
+ for i, b := range boxes {
+ c := b.GetConf()
+ c.Sort = i + 1
+ b.SaveConf(c)
+ }
+
id = ast.NewNodeID()
boxLocalPath := filepath.Join(util.DataDir, id)
err = os.MkdirAll(boxLocalPath, 0755)