🎨 Add internal kernel API /api/filetree/upsertIndexes and /api/filetree/removeIndexes https://github.com/siyuan-note/siyuan/issues/10079

This commit is contained in:
Daniel 2024-01-05 20:54:46 +08:00
parent 318e570343
commit 286654cb00
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
5 changed files with 112 additions and 13 deletions

View file

@ -277,13 +277,14 @@ func incReindex(upserts, removes []string) (upsertRootIDs, removeRootIDs []strin
removeRootIDs = []string{}
util.IncBootProgress(3, "Sync reindexing...")
msg := fmt.Sprintf(Conf.Language(35))
util.PushStatusBar(msg)
removeRootIDs = removeIndexes(removes) // 先执行 remove否则移动文档时 upsert 会被忽略,导致未被索引
upsertRootIDs = upsertIndexes(upserts)
return
}
luteEngine := util.NewLute()
// 先执行 remove否则移动文档时 upsert 会被忽略,导致未被索引
bootProgressPart := int32(10 / float64(len(removes)))
for _, removeFile := range removes {
func removeIndexes(removeFilePaths []string) (removeRootIDs []string) {
bootProgressPart := int32(10 / float64(len(removeFilePaths)))
for _, removeFile := range removeFilePaths {
if !strings.HasSuffix(removeFile, ".sy") {
continue
}
@ -292,7 +293,7 @@ func incReindex(upserts, removes []string) (upsertRootIDs, removeRootIDs []strin
removeRootIDs = append(removeRootIDs, id)
block := treenode.GetBlockTree(id)
if nil != block {
msg = fmt.Sprintf(Conf.Language(39), block.RootID)
msg := fmt.Sprintf(Conf.Language(39), block.RootID)
util.IncBootProgress(bootProgressPart, msg)
util.PushStatusBar(msg)
@ -300,12 +301,13 @@ func incReindex(upserts, removes []string) (upsertRootIDs, removeRootIDs []strin
sql.RemoveTreeQueue(block.BoxID, block.RootID)
}
}
return
}
msg = fmt.Sprintf(Conf.Language(35))
util.PushStatusBar(msg)
bootProgressPart = int32(10 / float64(len(upserts)))
for _, upsertFile := range upserts {
func upsertIndexes(upsertFilePaths []string) (upsertRootIDs []string) {
luteEngine := util.NewLute()
bootProgressPart := int32(10 / float64(len(upsertFilePaths)))
for _, upsertFile := range upsertFilePaths {
if !strings.HasSuffix(upsertFile, ".sy") {
continue
}
@ -322,7 +324,7 @@ func incReindex(upserts, removes []string) (upsertRootIDs, removeRootIDs []strin
box := upsertFile[:idx]
p := strings.TrimPrefix(upsertFile, box)
msg = fmt.Sprintf(Conf.Language(40), strings.TrimSuffix(path.Base(p), ".sy"))
msg := fmt.Sprintf(Conf.Language(40), strings.TrimSuffix(path.Base(p), ".sy"))
util.IncBootProgress(bootProgressPart, msg)
util.PushStatusBar(msg)