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/7113
This commit is contained in:
parent
2e773ade52
commit
0a2d095d00
3 changed files with 60 additions and 6 deletions
|
|
@ -20,6 +20,7 @@ import (
|
|||
"bytes"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
|
|
@ -982,6 +983,42 @@ func deleteByRootID(tx *sql.Tx, rootID string, context map[string]interface{}) (
|
|||
return
|
||||
}
|
||||
|
||||
func batchDeleteByRootIDs(tx *sql.Tx, rootIDs []string, context map[string]interface{}) (err error) {
|
||||
ids := strings.Join(rootIDs, "','")
|
||||
ids = "('" + ids + "')"
|
||||
stmt := "DELETE FROM blocks WHERE root_id IN " + ids
|
||||
if err = execStmtTx(tx, stmt); nil != err {
|
||||
return
|
||||
}
|
||||
stmt = "DELETE FROM blocks_fts WHERE root_id IN " + ids
|
||||
if err = execStmtTx(tx, stmt); nil != err {
|
||||
return
|
||||
}
|
||||
stmt = "DELETE FROM blocks_fts_case_insensitive WHERE root_id IN " + ids
|
||||
if err = execStmtTx(tx, stmt); nil != err {
|
||||
return
|
||||
}
|
||||
stmt = "DELETE FROM spans WHERE root_id IN " + ids
|
||||
if err = execStmtTx(tx, stmt); nil != err {
|
||||
return
|
||||
}
|
||||
stmt = "DELETE FROM assets WHERE root_id IN " + ids
|
||||
if err = execStmtTx(tx, stmt); nil != err {
|
||||
return
|
||||
}
|
||||
stmt = "DELETE FROM refs WHERE root_id IN " + ids
|
||||
if err = execStmtTx(tx, stmt); nil != err {
|
||||
return
|
||||
}
|
||||
stmt = "DELETE FROM file_annotation_refs WHERE root_id IN " + ids
|
||||
if err = execStmtTx(tx, stmt); nil != err {
|
||||
return
|
||||
}
|
||||
ClearBlockCache()
|
||||
eventbus.Publish(eventbus.EvtSQLDeleteBlocks, context, fmt.Sprintf("%d", len(rootIDs)))
|
||||
return
|
||||
}
|
||||
|
||||
func batchDeleteByPathPrefix(tx *sql.Tx, boxID, pathPrefix string) (err error) {
|
||||
stmt := "DELETE FROM blocks WHERE box = ? AND path LIKE ?"
|
||||
if err = execStmtTx(tx, stmt, boxID, pathPrefix+"%"); nil != err {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue