🎨 Alt+5 打开已有日记时不在内核伺服客户端之间同步 Fix https://github.com/siyuan-note/siyuan/issues/5617

This commit is contained in:
Liang Ding 2022-10-21 11:35:02 +08:00
parent 9fb4d9da2a
commit 8ac1104d6f
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
5 changed files with 41 additions and 11 deletions

View file

@ -1012,7 +1012,7 @@ func CreateWithMarkdown(boxID, hPath, md string) (id string, err error) {
WaitForWritingFiles()
luteEngine := NewLute()
dom := luteEngine.Md2BlockDOM(md)
id, err = createDocsByHPath(box.ID, hPath, dom)
id, _, err = createDocsByHPath(box.ID, hPath, dom)
return
}
@ -1311,7 +1311,7 @@ func RenameDoc(boxID, p, title string) (err error) {
return
}
func CreateDailyNote(boxID string) (p string, err error) {
func CreateDailyNote(boxID string) (p string, existed bool, err error) {
box := Conf.Box(boxID)
if nil == box {
err = ErrBoxNotFound
@ -1333,11 +1333,12 @@ func CreateDailyNote(boxID string) (p string, err error) {
existRoot := treenode.GetBlockTreeRootByHPath(box.ID, hPath)
if nil != existRoot {
existed = true
p = existRoot.Path
return
}
id, err := createDocsByHPath(box.ID, hPath, "")
id, existed, err := createDocsByHPath(box.ID, hPath, "")
if nil != err {
return
}

View file

@ -33,9 +33,9 @@ import (
"github.com/siyuan-note/siyuan/kernel/util"
)
func createDocsByHPath(boxID, hPath, content string) (id string, err error) {
func createDocsByHPath(boxID, hPath, content string) (id string, existed bool, err error) {
hPath = strings.TrimSuffix(hPath, ".sy")
if docExist := nil != treenode.GetBlockTreeRootByHPath(boxID, hPath); docExist {
if existed = nil != treenode.GetBlockTreeRootByHPath(boxID, hPath); existed {
hPath += "-" + gulu.Rand.String(7)
}
pathBuilder := bytes.Buffer{}