mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 00:50:13 +01:00
This commit is contained in:
parent
3a93650d9d
commit
2cb6e82330
6 changed files with 79 additions and 10 deletions
|
|
@ -55,9 +55,11 @@ func updateRootContent(tx *sql.Tx, content, updated, id string) {
|
|||
if err := execStmtTx(tx, stmt, content, content, updated, id); nil != err {
|
||||
return
|
||||
}
|
||||
stmt = "UPDATE blocks_fts_case_insensitive SET content = ?, fcontent = ?, updated = ? WHERE id = ?"
|
||||
if err := execStmtTx(tx, stmt, content, content, updated, id); nil != err {
|
||||
return
|
||||
if !caseSensitive {
|
||||
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)
|
||||
|
|
@ -66,3 +68,30 @@ func updateRootContent(tx *sql.Tx, content, updated, id string) {
|
|||
func InsertBlock(tx *sql.Tx, block *Block, context map[string]interface{}) (err error) {
|
||||
return insertBlocks(tx, []*Block{block}, context)
|
||||
}
|
||||
|
||||
func UpdateBlockContent(block *Block) {
|
||||
tx, err := BeginTx()
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
stmt := "UPDATE blocks SET content = ? WHERE id = ?"
|
||||
if err = execStmtTx(tx, stmt, block.Content, block.ID); nil != err {
|
||||
tx.Rollback()
|
||||
return
|
||||
}
|
||||
stmt = "UPDATE blocks_fts SET content = ? WHERE id = ?"
|
||||
if err = execStmtTx(tx, stmt, block.Content, block.ID); nil != err {
|
||||
tx.Rollback()
|
||||
return
|
||||
}
|
||||
if !caseSensitive {
|
||||
stmt = "UPDATE blocks_fts_case_insensitive SET content = ? WHERE id = ?"
|
||||
if err = execStmtTx(tx, stmt, block.Content, block.ID); nil != err {
|
||||
tx.Rollback()
|
||||
return
|
||||
}
|
||||
}
|
||||
tx.Commit()
|
||||
putBlockCache(block)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue