This commit is contained in:
Daniel 2024-05-12 22:45:04 +08:00
parent 84819beaf7
commit b959cc2beb
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
9 changed files with 27 additions and 7 deletions

View file

@ -112,6 +112,11 @@ func unindex(boxID string) {
ids := treenode.RemoveBlockTreesByBoxID(boxID)
RemoveRecentDoc(ids)
sql.DeleteBoxQueue(boxID)
go func() {
sql.WaitForWritingDatabase()
ResetVirtualBlockRefCache()
}()
}
func (box *Box) Index() {

View file

@ -31,6 +31,7 @@ import (
"github.com/dgraph-io/ristretto"
"github.com/siyuan-note/siyuan/kernel/search"
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/task"
"github.com/siyuan-note/siyuan/kernel/treenode"
)
@ -99,6 +100,13 @@ func putBlockVirtualRefKeywords(blockContent string, root *ast.Node) (ret []stri
}
func CacheVirtualBlockRefJob() {
if !Conf.Editor.VirtualBlockRef {
return
}
task.AppendTask(task.CacheVirtualBlockRef, ResetVirtualBlockRefCache)
}
func cacheVirtualBlockRef() {
virtualBlockRefCache.Del("virtual_ref")
if !Conf.Editor.VirtualBlockRef {
return
@ -110,7 +118,7 @@ func CacheVirtualBlockRefJob() {
func ResetVirtualBlockRefCache() {
virtualBlockRefCache.Clear()
CacheVirtualBlockRefJob()
cacheVirtualBlockRef()
}
func AddVirtualBlockRefInclude(keyword []string) {

View file

@ -99,6 +99,7 @@ const (
ReloadUI = "task.reload.ui" // 重载 UI
AssetContentDatabaseIndexFull = "task.asset.database.index.full" // 资源文件数据库重建索引
AssetContentDatabaseIndexCommit = "task.asset.database.index.commit" // 资源文件数据库索引提交
CacheVirtualBlockRef = "task.cache.virtualBlockRef" // 缓存虚拟块引用
)
// uniqueActions 描述了唯一的任务,即队列中只能存在一个在执行的任务。