mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 03:40:04 -06:00
This commit is contained in:
@@ -18,6 +18,7 @@ package sql
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/sha256"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -1093,7 +1094,7 @@ func batchDeleteByPathPrefix(tx *sql.Tx, boxID, pathPrefix string) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func batchUpdateHPath(tx *sql.Tx, boxID, rootID, newHPath string) (err error) {
|
||||
func batchUpdateHPath(tx *sql.Tx, boxID, rootID, newHPath string, context map[string]interface{}) (err error) {
|
||||
stmt := "UPDATE blocks SET hpath = ? WHERE box = ? AND root_id = ?"
|
||||
if err = execStmtTx(tx, stmt, newHPath, boxID, rootID); nil != err {
|
||||
return
|
||||
@@ -1109,6 +1110,8 @@ func batchUpdateHPath(tx *sql.Tx, boxID, rootID, newHPath string) (err error) {
|
||||
}
|
||||
}
|
||||
ClearCache()
|
||||
evtHash := fmt.Sprintf("%x", sha256.Sum256([]byte(rootID)))[:7]
|
||||
eventbus.Publish(eventbus.EvtSQLInsertBlocksFTS, context, 1, evtHash)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -167,13 +167,13 @@ func execOp(op *dbQueueOperation, tx *sql.Tx, context map[string]interface{}) (e
|
||||
case "delete_ids":
|
||||
err = batchDeleteByRootIDs(tx, op.removeTreeIDs, context)
|
||||
case "rename":
|
||||
err = batchUpdateHPath(tx, op.renameTree.Box, op.renameTree.ID, op.renameTree.HPath)
|
||||
err = batchUpdateHPath(tx, op.renameTree.Box, op.renameTree.ID, op.renameTree.HPath, context)
|
||||
if nil != err {
|
||||
break
|
||||
}
|
||||
err = updateRootContent(tx, path.Base(op.renameTree.HPath), op.renameTree.Root.IALAttr("updated"), op.renameTree.ID)
|
||||
case "rename_sub_tree":
|
||||
err = batchUpdateHPath(tx, op.renameTree.Box, op.renameTree.ID, op.renameTree.HPath)
|
||||
err = batchUpdateHPath(tx, op.renameTree.Box, op.renameTree.ID, op.renameTree.HPath, context)
|
||||
case "delete_box":
|
||||
err = deleteByBoxTx(tx, op.box)
|
||||
case "delete_box_refs":
|
||||
|
||||
Reference in New Issue
Block a user