mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🎨 Improve reindexing
This commit is contained in:
parent
49c25a28e4
commit
ff6c154bfa
2 changed files with 9 additions and 3 deletions
|
|
@ -502,6 +502,7 @@ func genTreeID(tree *parse.Tree) {
|
||||||
func FullReindex() {
|
func FullReindex() {
|
||||||
task.AppendTask(task.DatabaseIndexFull, fullReindex)
|
task.AppendTask(task.DatabaseIndexFull, fullReindex)
|
||||||
task.AppendTask(task.DatabaseIndexRef, IndexRefs)
|
task.AppendTask(task.DatabaseIndexRef, IndexRefs)
|
||||||
|
task.AppendTaskWithTimeout(task.DatabaseIndexEmbedBlock, 30*time.Second, autoIndexEmbedBlock)
|
||||||
task.AppendTask(task.ReloadUI, util.ReloadUI)
|
task.AppendTask(task.ReloadUI, util.ReloadUI)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -282,13 +282,18 @@ func IndexRefs() {
|
||||||
ResetVirtualBlockRefCache()
|
ResetVirtualBlockRefCache()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var indexEmbedBlockLock = sync.Mutex{}
|
||||||
|
|
||||||
// IndexEmbedBlockJob 嵌入块支持搜索 https://github.com/siyuan-note/siyuan/issues/7112
|
// IndexEmbedBlockJob 嵌入块支持搜索 https://github.com/siyuan-note/siyuan/issues/7112
|
||||||
func IndexEmbedBlockJob() {
|
func IndexEmbedBlockJob() {
|
||||||
embedBlocks := sql.QueryEmptyContentEmbedBlocks()
|
task.AppendTaskWithTimeout(task.DatabaseIndexEmbedBlock, 30*time.Second, autoIndexEmbedBlock)
|
||||||
task.AppendTaskWithTimeout(task.DatabaseIndexEmbedBlock, 30*time.Second, autoIndexEmbedBlock, embedBlocks)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func autoIndexEmbedBlock(embedBlocks []*sql.Block) {
|
func autoIndexEmbedBlock() {
|
||||||
|
indexEmbedBlockLock.Lock()
|
||||||
|
defer indexEmbedBlockLock.Unlock()
|
||||||
|
|
||||||
|
embedBlocks := sql.QueryEmptyContentEmbedBlocks()
|
||||||
for i, embedBlock := range embedBlocks {
|
for i, embedBlock := range embedBlocks {
|
||||||
markdown := strings.TrimSpace(embedBlock.Markdown)
|
markdown := strings.TrimSpace(embedBlock.Markdown)
|
||||||
markdown = strings.TrimPrefix(markdown, "{{")
|
markdown = strings.TrimPrefix(markdown, "{{")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue