mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🐛 索引嵌入块内容可能会导致内核崩溃 https://github.com/siyuan-note/siyuan/issues/7213
This commit is contained in:
parent
dbf6965c30
commit
204580bf36
4 changed files with 29 additions and 14 deletions
|
|
@ -41,7 +41,7 @@ var (
|
|||
|
||||
type dbQueueOperation struct {
|
||||
inQueueTime time.Time
|
||||
action string // upsert/delete/delete_id/rename/delete_box/delete_box_refs/insert_refs/index/delete_ids
|
||||
action string // upsert/delete/delete_id/rename/delete_box/delete_box_refs/insert_refs/index/delete_ids/update_block_content
|
||||
|
||||
indexPath string // index
|
||||
upsertTree *parse.Tree // upsert/insert_refs
|
||||
|
|
@ -51,6 +51,7 @@ type dbQueueOperation struct {
|
|||
box string // delete_box/delete_box_refs/index
|
||||
renameTree *parse.Tree // rename
|
||||
renameTreeOldHPath string // rename
|
||||
block *Block // update_block_content
|
||||
}
|
||||
|
||||
func FlushTxJob() {
|
||||
|
|
@ -166,6 +167,8 @@ func execOp(op *dbQueueOperation, tx *sql.Tx, context map[string]interface{}) (e
|
|||
err = insertRefs(tx, op.upsertTree)
|
||||
case "update_refs":
|
||||
err = upsertRefs(tx, op.upsertTree)
|
||||
case "update_block_content":
|
||||
err = updateBlockContent(tx, op.block)
|
||||
default:
|
||||
msg := fmt.Sprintf("unknown operation [%s]", op.action)
|
||||
logging.LogErrorf(msg)
|
||||
|
|
@ -174,13 +177,18 @@ func execOp(op *dbQueueOperation, tx *sql.Tx, context map[string]interface{}) (e
|
|||
return
|
||||
}
|
||||
|
||||
func mergeUpsertTrees() (ops []*dbQueueOperation) {
|
||||
func UpdateBlockContentQueue(block *Block) {
|
||||
dbQueueLock.Lock()
|
||||
defer dbQueueLock.Unlock()
|
||||
|
||||
ops = operationQueue
|
||||
operationQueue = nil
|
||||
return
|
||||
newOp := &dbQueueOperation{block: block, inQueueTime: time.Now(), action: "update_block_content"}
|
||||
for i, op := range operationQueue {
|
||||
if "update_block_content" == op.action && op.block.ID == block.ID {
|
||||
operationQueue[i] = newOp
|
||||
return
|
||||
}
|
||||
}
|
||||
operationQueue = append(operationQueue, newOp)
|
||||
}
|
||||
|
||||
func UpdateRefsTreeQueue(tree *parse.Tree) {
|
||||
|
|
@ -320,3 +328,12 @@ func RemoveTreePathQueue(treeBox, treePathPrefix string) {
|
|||
}
|
||||
operationQueue = append(operationQueue, newOp)
|
||||
}
|
||||
|
||||
func mergeUpsertTrees() (ops []*dbQueueOperation) {
|
||||
dbQueueLock.Lock()
|
||||
defer dbQueueLock.Unlock()
|
||||
|
||||
ops = operationQueue
|
||||
operationQueue = nil
|
||||
return
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue