Skip to content

Commit 2ba42bb

Browse files
committed
🎨 Add the custom-dailynote-yyyyMMdd attribute when creating a dailynote doc #9807
1 parent 0d9b8fe commit 2ba42bb

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

kernel/model/file.go

+15-2
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,20 @@ func CreateDailyNote(boxID string) (p string, existed bool, err error) {
10761076
if nil != existRoot {
10771077
existed = true
10781078
p = existRoot.Path
1079+
1080+
tree, loadErr := loadTreeByBlockID(existRoot.RootID)
1081+
if nil != loadErr {
1082+
logging.LogWarnf("load tree by block id [%s] failed: %v", existRoot.RootID, loadErr)
1083+
return
1084+
}
1085+
p = tree.Path
1086+
date := time.Now().Format("20060102")
1087+
if tree.Root.IALAttr("custom-dailynote-"+date) == "" {
1088+
tree.Root.SetIALAttr("custom-dailynote-"+date, date)
1089+
if err = indexWriteJSONQueue(tree); nil != err {
1090+
return
1091+
}
1092+
}
10791093
return
10801094
}
10811095

@@ -1127,8 +1141,7 @@ func CreateDailyNote(boxID string) (p string, existed bool, err error) {
11271141
return
11281142
}
11291143
p = tree.Path
1130-
date := util.TimeFromID(id)
1131-
date = date[:len("yyyyMMdd")]
1144+
date := time.Now().Format("20060102")
11321145
tree.Root.SetIALAttr("custom-dailynote-"+date, date)
11331146
if err = indexWriteJSONQueue(tree); nil != err {
11341147
return

0 commit comments

Comments
 (0)