Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Automatically perform index fixing during idle time https://github.com/siyuan-note/siyuan/issues/17535

Daniel14db465d7e7f
diff --git a/kernel/model/index_fix.go b/kernel/model/index_fix.go
index 94e7e9c142..07f401a8b4 100644
--- a/kernel/model/index_fix.go
+++ b/kernel/model/index_fix.go
@@ -70,10 +70,19 @@ func checkIndex() {
fixIndexMu.Lock()
defer fixIndexMu.Unlock()
- fixIndexPipeline()
+ runFixIndexPipeline()
})
}
+// runFixIndexPipeline 执行索引订正流水线并完成收尾(清除脏标志、记录订正时间)。
+// 调用方需持有 fixIndexMu。
+func runFixIndexPipeline() {
+ fixIndexPipeline()
+ // 收尾:清除脏标志并记录订正时间,避免在冷却期内被 AutoFixIndex 重复触发
+ util.MarkIndexClean()
+ lastFixedAt = time.Now()
+}
+
// fixIndexPipeline 执行索引订正流水线。
// 由 checkIndex(同步后一次性)与 AutoFixIndex(空闲触发)共用,调用方负责加 fixIndexMu 互斥锁。
func fixIndexPipeline() {
@@ -129,9 +138,7 @@ func AutoFixIndex() {
}
logging.LogInfof("start auto fixing index on idle...")
- fixIndexPipeline()
- util.MarkIndexClean()
- lastFixedAt = time.Now()
+ runFixIndexPipeline()
logging.LogInfof("finish auto fixing index on idle")
}