Browse Source

:bug: v202301271540 logging.go panic 异常,导致内核崩溃 Fix https://github.com/siyuan-note/siyuan/issues/7179

Liang Ding 2 years ago
parent
commit
6e02ffd7f5
1 changed files with 8 additions and 1 deletions
  1. 8 1
      kernel/filesys/tree.go

+ 8 - 1
kernel/filesys/tree.go

@@ -91,6 +91,9 @@ func LoadTree(boxID, p string, luteEngine *lute.Lute) (ret *parse.Tree, err erro
 		}
 
 		ial := ReadDocIAL(parentData)
+		if 1 > len(ial) {
+			logging.LogWarnf("tree [%s] is corrupted", filePath)
+		}
 		title := ial["title"]
 		if "" == title {
 			title = "Untitled"
@@ -266,6 +269,10 @@ func parseJSON2Tree(boxID, p string, jsonData []byte, luteEngine *lute.Lute) (re
 
 func ReadDocIAL(data []byte) (ret map[string]string) {
 	ret = map[string]string{}
-	jsoniter.Get(data, "Properties").ToVal(&ret)
+	val := jsoniter.Get(data, "Properties")
+	if nil == val {
+		return
+	}
+	val.ToVal(&ret)
 	return
 }