🐛 Subdocument path not updated after moving parent document https://github.com/siyuan-note/siyuan/issues/12493
This commit is contained in:
parent
22ffd923d3
commit
c67ff98972
2 changed files with 31 additions and 10 deletions
|
@ -1251,23 +1251,44 @@ func batchDeleteByPathPrefix(tx *sql.Tx, boxID, pathPrefix string) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func batchUpdateHPath(tx *sql.Tx, rootID, newHPath string, context map[string]interface{}) (err error) {
|
||||
stmt := "UPDATE blocks SET hpath = ? WHERE root_id = ?"
|
||||
if err = execStmtTx(tx, stmt, newHPath, rootID); err != nil {
|
||||
func batchUpdatePath(tx *sql.Tx, tree *parse.Tree, context map[string]interface{}) (err error) {
|
||||
stmt := "UPDATE blocks SET box = ?, path = ?, hpath = ? WHERE root_id = ?"
|
||||
if err = execStmtTx(tx, stmt, tree.Box, tree.Path, tree.HPath, tree.ID); err != nil {
|
||||
return
|
||||
}
|
||||
stmt = "UPDATE blocks_fts SET hpath = ? WHERE root_id = ?"
|
||||
if err = execStmtTx(tx, stmt, newHPath, rootID); err != nil {
|
||||
stmt = "UPDATE blocks_fts SET box = ?, path = ?, hpath = ? WHERE root_id = ?"
|
||||
if err = execStmtTx(tx, stmt, tree.Box, tree.Path, tree.HPath, tree.ID); err != nil {
|
||||
return
|
||||
}
|
||||
if !caseSensitive {
|
||||
stmt = "UPDATE blocks_fts_case_insensitive SET hpath = ? WHERE root_id = ?"
|
||||
if err = execStmtTx(tx, stmt, newHPath, rootID); err != nil {
|
||||
stmt = "UPDATE blocks_fts_case_insensitive SET box = ?, path = ?, hpath = ? WHERE root_id = ?"
|
||||
if err = execStmtTx(tx, stmt, tree.Box, tree.Path, tree.HPath, tree.ID); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
ClearCache()
|
||||
evtHash := fmt.Sprintf("%x", sha256.Sum256([]byte(rootID)))[:7]
|
||||
evtHash := fmt.Sprintf("%x", sha256.Sum256([]byte(tree.ID)))[:7]
|
||||
eventbus.Publish(eventbus.EvtSQLUpdateBlocksHPaths, context, 1, evtHash)
|
||||
return
|
||||
}
|
||||
|
||||
func batchUpdateHPath(tx *sql.Tx, tree *parse.Tree, context map[string]interface{}) (err error) {
|
||||
stmt := "UPDATE blocks SET hpath = ? WHERE root_id = ?"
|
||||
if err = execStmtTx(tx, stmt, tree.HPath, tree.ID); err != nil {
|
||||
return
|
||||
}
|
||||
stmt = "UPDATE blocks_fts SET hpath = ? WHERE root_id = ?"
|
||||
if err = execStmtTx(tx, stmt, tree.HPath, tree.ID); err != nil {
|
||||
return
|
||||
}
|
||||
if !caseSensitive {
|
||||
stmt = "UPDATE blocks_fts_case_insensitive SET hpath = ? WHERE root_id = ?"
|
||||
if err = execStmtTx(tx, stmt, tree.HPath, tree.ID); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
ClearCache()
|
||||
evtHash := fmt.Sprintf("%x", sha256.Sum256([]byte(tree.ID)))[:7]
|
||||
eventbus.Publish(eventbus.EvtSQLUpdateBlocksHPaths, context, 1, evtHash)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -187,13 +187,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.ID, op.renameTree.HPath, context)
|
||||
err = batchUpdateHPath(tx, op.renameTree, context)
|
||||
if err != nil {
|
||||
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.ID, op.renameTree.HPath, context)
|
||||
err = batchUpdatePath(tx, op.renameTree, context)
|
||||
case "delete_box":
|
||||
err = deleteByBoxTx(tx, op.box)
|
||||
case "delete_box_refs":
|
||||
|
|
Loading…
Add table
Reference in a new issue