Browse Source

:art: Add the `custom-dailynote-yyyyMMdd` attribute when creating a dailynote doc https://github.com/siyuan-note/siyuan/issues/9807

Daniel 1 year ago
parent
commit
773a6f5ec2
1 changed files with 15 additions and 2 deletions
  1. 15 2
      kernel/model/file.go

+ 15 - 2
kernel/model/file.go

@@ -1119,8 +1119,21 @@ func CreateDailyNote(boxID string) (p string, existed bool, err error) {
 	}
 	IncSync()
 
-	b := treenode.GetBlockTree(id)
-	p = b.Path
+	WaitForWritingFiles()
+
+	tree, err := loadTreeByBlockID(id)
+	if nil != err {
+		logging.LogErrorf("load tree by block id [%s] failed: %v", id, err)
+		return
+	}
+	p = tree.Path
+	date := util.TimeFromID(id)
+	date = date[:len("yyyyMMdd")]
+	tree.Root.SetIALAttr("custom-dailynote-"+date, date)
+	if err = indexWriteJSONQueue(tree); nil != err {
+		return
+	}
+
 	return
 }