🎨 Improve reindexing

This commit is contained in:
Daniel 2024-05-10 16:20:02 +08:00
parent 49c25a28e4
commit ff6c154bfa
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 9 additions and 3 deletions

View file

@ -502,6 +502,7 @@ func genTreeID(tree *parse.Tree) {
func FullReindex() {
task.AppendTask(task.DatabaseIndexFull, fullReindex)
task.AppendTask(task.DatabaseIndexRef, IndexRefs)
task.AppendTaskWithTimeout(task.DatabaseIndexEmbedBlock, 30*time.Second, autoIndexEmbedBlock)
task.AppendTask(task.ReloadUI, util.ReloadUI)
}

View file

@ -282,13 +282,18 @@ func IndexRefs() {
ResetVirtualBlockRefCache()
}
var indexEmbedBlockLock = sync.Mutex{}
// IndexEmbedBlockJob 嵌入块支持搜索 https://github.com/siyuan-note/siyuan/issues/7112
func IndexEmbedBlockJob() {
embedBlocks := sql.QueryEmptyContentEmbedBlocks()
task.AppendTaskWithTimeout(task.DatabaseIndexEmbedBlock, 30*time.Second, autoIndexEmbedBlock, embedBlocks)
task.AppendTaskWithTimeout(task.DatabaseIndexEmbedBlock, 30*time.Second, autoIndexEmbedBlock)
}
func autoIndexEmbedBlock(embedBlocks []*sql.Block) {
func autoIndexEmbedBlock() {
indexEmbedBlockLock.Lock()
defer indexEmbedBlockLock.Unlock()
embedBlocks := sql.QueryEmptyContentEmbedBlocks()
for i, embedBlock := range embedBlocks {
markdown := strings.TrimSpace(embedBlock.Markdown)
markdown = strings.TrimPrefix(markdown, "{{")