From 39b4587eb50ba3dd49bf6dbe60a61f0bf33a3552 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Sat, 3 Sep 2022 12:14:41 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E5=8C=85=E5=90=AB=E8=BE=83=E5=A4=A7?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E7=9A=84=E6=96=87=E6=A1=A3=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E4=B8=8D=E5=85=A8=20https://github.com/siyuan-note/siyuan/issu?= =?UTF-8?q?es/5798?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/api/filetree.go | 25 +++++++++++++------------ kernel/model/file.go | 3 ++- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/kernel/api/filetree.go b/kernel/api/filetree.go index 18be6e444..3151160e8 100644 --- a/kernel/api/filetree.go +++ b/kernel/api/filetree.go @@ -634,7 +634,7 @@ func getDoc(c *gin.Context) { size = 36 } - blockCount, content, parentID, parent2ID, rootID, typ, eof, boxID, docPath, err := model.GetDoc(startID, endID, id, index, keyword, mode, size) + blockCount, childBlockCount, content, parentID, parent2ID, rootID, typ, eof, boxID, docPath, err := model.GetDoc(startID, endID, id, index, keyword, mode, size) if errors.Is(err, filelock.ErrUnableLockFile) { ret.Code = 2 ret.Data = id @@ -652,17 +652,18 @@ func getDoc(c *gin.Context) { } ret.Data = map[string]interface{}{ - "id": id, - "mode": mode, - "parentID": parentID, - "parent2ID": parent2ID, - "rootID": rootID, - "type": typ, - "content": content, - "blockCount": blockCount, - "eof": eof, - "box": boxID, - "path": docPath, + "id": id, + "mode": mode, + "parentID": parentID, + "parent2ID": parent2ID, + "rootID": rootID, + "type": typ, + "content": content, + "blockCount": blockCount, + "childBlockCount": childBlockCount, + "eof": eof, + "box": boxID, + "path": docPath, } } diff --git a/kernel/model/file.go b/kernel/model/file.go index 55785b479..e8c09432a 100644 --- a/kernel/model/file.go +++ b/kernel/model/file.go @@ -421,7 +421,7 @@ func BlockWordCount(id string) (blockRuneCount, blockWordCount, rootBlockRuneCou return } -func GetDoc(startID, endID, id string, index int, keyword string, mode int, size int) (blockCount int, dom, parentID, parent2ID, rootID, typ string, eof bool, boxID, docPath string, err error) { +func GetDoc(startID, endID, id string, index int, keyword string, mode int, size int) (blockCount, childBlockCount int, dom, parentID, parent2ID, rootID, typ string, eof bool, boxID, docPath string, err error) { WaitForWritingFiles() // 写入数据时阻塞,避免获取到的数据不一致 inputIndex := index @@ -529,6 +529,7 @@ func GetDoc(startID, endID, id string, index int, keyword string, mode int, size } blockCount = tree.DocBlockCount() + childBlockCount = treenode.CountBlockNodes(tree.Root) if ast.NodeDocument == node.Type { parentID = node.ID parent2ID = parentID