🎨 文档重命名后变更文档更新时间 Fix https://github.com/siyuan-note/siyuan/issues/5792

This commit is contained in:
Liang Ding 2022-09-02 16:26:05 +08:00
parent 078ea5c793
commit a09e201f99
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 24 additions and 16 deletions

View file

@ -18,6 +18,8 @@ package sql
import (
"database/sql"
"github.com/siyuan-note/siyuan/kernel/cache"
)
type Block struct {
@ -44,20 +46,21 @@ type Block struct {
Updated string
}
func updateRootContent(tx *sql.Tx, content, id string) {
stmt := "UPDATE blocks SET content = ?, fcontent = ? WHERE id = ?"
if err := execStmtTx(tx, stmt, content, content, id); nil != err {
func updateRootContent(tx *sql.Tx, content, updated, id string) {
stmt := "UPDATE blocks SET content = ?, fcontent = ?, updated = ? WHERE id = ?"
if err := execStmtTx(tx, stmt, content, content, updated, id); nil != err {
return
}
stmt = "UPDATE blocks_fts SET content = ?, fcontent = ? WHERE id = ?"
if err := execStmtTx(tx, stmt, content, content, id); nil != err {
stmt = "UPDATE blocks_fts SET content = ?, fcontent = ?, updated = ? WHERE id = ?"
if err := execStmtTx(tx, stmt, content, content, updated, id); nil != err {
return
}
stmt = "UPDATE blocks_fts_case_insensitive SET content = ?, fcontent = ? WHERE id = ?"
if err := execStmtTx(tx, stmt, content, content, id); nil != err {
stmt = "UPDATE blocks_fts_case_insensitive SET content = ?, fcontent = ?, updated = ? WHERE id = ?"
if err := execStmtTx(tx, stmt, content, content, updated, id); nil != err {
return
}
removeBlockCache(id)
cache.RemoveBlockIAL(id)
}
func InsertBlock(tx *sql.Tx, block *Block) (err error) {