mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-18 07:30:12 +01:00
⚡ Optimize document moving and renaming performance https://github.com/siyuan-note/siyuan/issues/10560
This commit is contained in:
parent
cf6ac5a807
commit
9bc6415c6a
2 changed files with 9 additions and 9 deletions
|
|
@ -1211,18 +1211,18 @@ func batchDeleteByPathPrefix(tx *sql.Tx, boxID, pathPrefix string) (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func batchUpdateHPath(tx *sql.Tx, boxID, rootID, newHPath string, context map[string]interface{}) (err error) {
|
func batchUpdateHPath(tx *sql.Tx, rootID, newHPath string, context map[string]interface{}) (err error) {
|
||||||
stmt := "UPDATE blocks SET hpath = ? WHERE box = ? AND root_id = ?"
|
stmt := "UPDATE blocks SET hpath = ? WHERE root_id = ?"
|
||||||
if err = execStmtTx(tx, stmt, newHPath, boxID, rootID); nil != err {
|
if err = execStmtTx(tx, stmt, newHPath, rootID); nil != err {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
stmt = "UPDATE blocks_fts SET hpath = ? WHERE box = ? AND root_id = ?"
|
stmt = "UPDATE blocks_fts SET hpath = ? WHERE root_id = ?"
|
||||||
if err = execStmtTx(tx, stmt, newHPath, boxID, rootID); nil != err {
|
if err = execStmtTx(tx, stmt, newHPath, rootID); nil != err {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !caseSensitive {
|
if !caseSensitive {
|
||||||
stmt = "UPDATE blocks_fts_case_insensitive SET hpath = ? WHERE box = ? AND root_id = ?"
|
stmt = "UPDATE blocks_fts_case_insensitive SET hpath = ? WHERE root_id = ?"
|
||||||
if err = execStmtTx(tx, stmt, newHPath, boxID, rootID); nil != err {
|
if err = execStmtTx(tx, stmt, newHPath, rootID); nil != err {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -174,13 +174,13 @@ func execOp(op *dbQueueOperation, tx *sql.Tx, context map[string]interface{}) (e
|
||||||
case "delete_ids":
|
case "delete_ids":
|
||||||
err = batchDeleteByRootIDs(tx, op.removeTreeIDs, context)
|
err = batchDeleteByRootIDs(tx, op.removeTreeIDs, context)
|
||||||
case "rename":
|
case "rename":
|
||||||
err = batchUpdateHPath(tx, op.renameTree.Box, op.renameTree.ID, op.renameTree.HPath, context)
|
err = batchUpdateHPath(tx, op.renameTree.ID, op.renameTree.HPath, context)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
err = updateRootContent(tx, path.Base(op.renameTree.HPath), op.renameTree.Root.IALAttr("updated"), op.renameTree.ID)
|
err = updateRootContent(tx, path.Base(op.renameTree.HPath), op.renameTree.Root.IALAttr("updated"), op.renameTree.ID)
|
||||||
case "rename_sub_tree":
|
case "rename_sub_tree":
|
||||||
err = batchUpdateHPath(tx, op.renameTree.Box, op.renameTree.ID, op.renameTree.HPath, context)
|
err = batchUpdateHPath(tx, op.renameTree.ID, op.renameTree.HPath, context)
|
||||||
case "delete_box":
|
case "delete_box":
|
||||||
err = deleteByBoxTx(tx, op.box)
|
err = deleteByBoxTx(tx, op.box)
|
||||||
case "delete_box_refs":
|
case "delete_box_refs":
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue