mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-20 22:14:06 +01:00
🐛 同步后需要重建索引的问题
This commit is contained in:
parent
c19109cb45
commit
d87e1de8ce
1 changed files with 21 additions and 18 deletions
|
|
@ -122,8 +122,28 @@ func SyncData(boot, exit, byHand bool) {
|
||||||
|
|
||||||
// incReindex 增量重建索引。
|
// incReindex 增量重建索引。
|
||||||
func incReindex(upserts, removes []string) {
|
func incReindex(upserts, removes []string) {
|
||||||
needPushUpsertProgress := 32 < len(upserts)
|
|
||||||
needPushRemoveProgress := 32 < len(removes)
|
needPushRemoveProgress := 32 < len(removes)
|
||||||
|
needPushUpsertProgress := 32 < len(upserts)
|
||||||
|
|
||||||
|
// 先执行 remove,否则移动文档时 upsert 会被忽略,导致未被索引
|
||||||
|
|
||||||
|
for _, removeFile := range removes {
|
||||||
|
if !strings.HasSuffix(removeFile, ".sy") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
id := strings.TrimSuffix(filepath.Base(removeFile), ".sy")
|
||||||
|
block := treenode.GetBlockTree(id)
|
||||||
|
if nil != block {
|
||||||
|
treenode.RemoveBlockTreesByRootID(block.RootID)
|
||||||
|
sql.RemoveTreeQueue(block.BoxID, block.RootID)
|
||||||
|
msg := fmt.Sprintf("Sync remove tree [%s]", block.RootID)
|
||||||
|
util.PushStatusBar(msg)
|
||||||
|
if needPushRemoveProgress {
|
||||||
|
util.PushEndlessProgress(msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for _, upsertFile := range upserts {
|
for _, upsertFile := range upserts {
|
||||||
if !strings.HasSuffix(upsertFile, ".sy") {
|
if !strings.HasSuffix(upsertFile, ".sy") {
|
||||||
|
|
@ -154,23 +174,6 @@ func incReindex(upserts, removes []string) {
|
||||||
util.PushEndlessProgress(msg)
|
util.PushEndlessProgress(msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, removeFile := range removes {
|
|
||||||
if !strings.HasSuffix(removeFile, ".sy") {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
id := strings.TrimSuffix(filepath.Base(removeFile), ".sy")
|
|
||||||
block := treenode.GetBlockTree(id)
|
|
||||||
if nil != block {
|
|
||||||
treenode.RemoveBlockTreesByRootID(block.RootID)
|
|
||||||
sql.RemoveTreeQueue(block.BoxID, block.RootID)
|
|
||||||
msg := fmt.Sprintf("Sync remove tree [%s]", block.RootID)
|
|
||||||
util.PushStatusBar(msg)
|
|
||||||
if needPushRemoveProgress {
|
|
||||||
util.PushEndlessProgress(msg)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if needPushRemoveProgress || needPushUpsertProgress {
|
if needPushRemoveProgress || needPushUpsertProgress {
|
||||||
util.PushClearProgress()
|
util.PushClearProgress()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue