mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
This commit is contained in:
parent
bc7b29bd0e
commit
bd153b89c5
3 changed files with 18 additions and 11 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/update_block_content
|
||||
action string // upsert/delete/delete_id/rename/delete_box/delete_box_refs/insert_refs/index/delete_ids/update_block_content/delete_assets
|
||||
|
||||
indexPath string // index
|
||||
upsertTree *parse.Tree // upsert/insert_refs
|
||||
|
|
@ -52,6 +52,7 @@ type dbQueueOperation struct {
|
|||
renameTree *parse.Tree // rename
|
||||
renameTreeOldHPath string // rename
|
||||
block *Block // update_block_content
|
||||
removeAssetHashes []string // delete_assets
|
||||
}
|
||||
|
||||
func FlushTxJob() {
|
||||
|
|
@ -169,6 +170,8 @@ func execOp(op *dbQueueOperation, tx *sql.Tx, context map[string]interface{}) (e
|
|||
err = upsertRefs(tx, op.upsertTree)
|
||||
case "update_block_content":
|
||||
err = updateBlockContent(tx, op.block)
|
||||
case "delete_assets":
|
||||
err = deleteAssetsByHashes(tx, op.removeAssetHashes)
|
||||
default:
|
||||
msg := fmt.Sprintf("unknown operation [%s]", op.action)
|
||||
logging.LogErrorf(msg)
|
||||
|
|
@ -177,6 +180,14 @@ func execOp(op *dbQueueOperation, tx *sql.Tx, context map[string]interface{}) (e
|
|||
return
|
||||
}
|
||||
|
||||
func BatchRemoveAssetsQueue(hashes []string) {
|
||||
dbQueueLock.Lock()
|
||||
defer dbQueueLock.Unlock()
|
||||
|
||||
newOp := &dbQueueOperation{removeAssetHashes: hashes, inQueueTime: time.Now(), action: "delete_assets"}
|
||||
operationQueue = append(operationQueue, newOp)
|
||||
}
|
||||
|
||||
func UpdateBlockContentQueue(block *Block) {
|
||||
dbQueueLock.Lock()
|
||||
defer dbQueueLock.Unlock()
|
||||
|
|
@ -336,4 +347,4 @@ func mergeUpsertTrees() (ops []*dbQueueOperation) {
|
|||
ops = operationQueue
|
||||
operationQueue = nil
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue