mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🐛 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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue