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