This commit is contained in:
Daniel 2024-06-27 21:29:31 +08:00
parent c9d3a50fd4
commit ed5c4738f9
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
5 changed files with 38 additions and 22 deletions

View file

@ -164,6 +164,8 @@ func FlushQueue() {
// Push database index commit event https://github.com/siyuan-note/siyuan/issues/8814
util.BroadcastByType("main", "databaseIndexCommit", 0, "", nil)
eventbus.Publish(eventbus.EvtSQLIndexFlushed)
}
func execOp(op *dbQueueOperation, tx *sql.Tx, context map[string]interface{}) (err error) {
@ -219,7 +221,7 @@ func IndexNodeQueue(id string) {
return
}
}
operationQueue = append(operationQueue, newOp)
appendOperation(newOp)
}
func BatchRemoveAssetsQueue(hashes []string) {
@ -231,7 +233,7 @@ func BatchRemoveAssetsQueue(hashes []string) {
defer dbQueueLock.Unlock()
newOp := &dbQueueOperation{removeAssetHashes: hashes, inQueueTime: time.Now(), action: "delete_assets"}
operationQueue = append(operationQueue, newOp)
appendOperation(newOp)
}
func UpdateBlockContentQueue(block *Block) {
@ -245,7 +247,7 @@ func UpdateBlockContentQueue(block *Block) {
return
}
}
operationQueue = append(operationQueue, newOp)
appendOperation(newOp)
}
func DeleteRefsTreeQueue(tree *parse.Tree) {
@ -259,7 +261,7 @@ func DeleteRefsTreeQueue(tree *parse.Tree) {
return
}
}
operationQueue = append(operationQueue, newOp)
appendOperation(newOp)
}
func UpdateRefsTreeQueue(tree *parse.Tree) {
@ -273,7 +275,7 @@ func UpdateRefsTreeQueue(tree *parse.Tree) {
return
}
}
operationQueue = append(operationQueue, newOp)
appendOperation(newOp)
}
func DeleteBoxRefsQueue(boxID string) {
@ -287,7 +289,7 @@ func DeleteBoxRefsQueue(boxID string) {
return
}
}
operationQueue = append(operationQueue, newOp)
appendOperation(newOp)
}
func DeleteBoxQueue(boxID string) {
@ -301,7 +303,7 @@ func DeleteBoxQueue(boxID string) {
return
}
}
operationQueue = append(operationQueue, newOp)
appendOperation(newOp)
}
func IndexTreeQueue(tree *parse.Tree) {
@ -315,7 +317,7 @@ func IndexTreeQueue(tree *parse.Tree) {
return
}
}
operationQueue = append(operationQueue, newOp)
appendOperation(newOp)
}
func UpsertTreeQueue(tree *parse.Tree) {
@ -329,7 +331,7 @@ func UpsertTreeQueue(tree *parse.Tree) {
return
}
}
operationQueue = append(operationQueue, newOp)
appendOperation(newOp)
}
func RenameTreeQueue(tree *parse.Tree) {
@ -347,7 +349,7 @@ func RenameTreeQueue(tree *parse.Tree) {
return
}
}
operationQueue = append(operationQueue, newOp)
appendOperation(newOp)
}
func RenameSubTreeQueue(tree *parse.Tree) {
@ -365,7 +367,7 @@ func RenameSubTreeQueue(tree *parse.Tree) {
return
}
}
operationQueue = append(operationQueue, newOp)
appendOperation(newOp)
}
func RemoveTreeQueue(rootID string) {
@ -379,7 +381,7 @@ func RemoveTreeQueue(rootID string) {
return
}
}
operationQueue = append(operationQueue, newOp)
appendOperation(newOp)
}
func BatchRemoveTreeQueue(rootIDs []string) {
@ -391,7 +393,7 @@ func BatchRemoveTreeQueue(rootIDs []string) {
defer dbQueueLock.Unlock()
newOp := &dbQueueOperation{removeTreeIDs: rootIDs, inQueueTime: time.Now(), action: "delete_ids"}
operationQueue = append(operationQueue, newOp)
appendOperation(newOp)
}
func RemoveTreePathQueue(treeBox, treePathPrefix string) {
@ -405,7 +407,7 @@ func RemoveTreePathQueue(treeBox, treePathPrefix string) {
return
}
}
operationQueue = append(operationQueue, newOp)
appendOperation(newOp)
}
func getOperations() (ops []*dbQueueOperation) {
@ -416,3 +418,8 @@ func getOperations() (ops []*dbQueueOperation) {
operationQueue = nil
return
}
func appendOperation(op *dbQueueOperation) {
operationQueue = append(operationQueue, op)
eventbus.Publish(eventbus.EvtSQLIndexChanged)
}