Skip to content

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

:art: 重建索引前清空数据库队列

Liang Ding248eecb87151
diff --git a/kernel/sql/database.go b/kernel/sql/database.go
index 1f46dd6d58..35c83d9466 100644
--- a/kernel/sql/database.go
+++ b/kernel/sql/database.go
@@ -64,6 +64,7 @@ func InitDatabase(forceRebuild bool) (err error) {
util.IncBootProgress(2, "Initializing database...")
if forceRebuild {
+ ClearQueue()
WaitForWritingDatabase()
}
diff --git a/kernel/sql/queue.go b/kernel/sql/queue.go
index 02e7960891..c9c71cfa2a 100644
--- a/kernel/sql/queue.go
+++ b/kernel/sql/queue.go
@@ -85,6 +85,12 @@ func IsEmptyQueue() bool {
return 1 > len(operationQueue) && !util.IsMutexLocked(&txLock)
}
+func ClearQueue() {
+ upsertTreeQueueLock.Lock()
+ defer upsertTreeQueueLock.Unlock()
+ operationQueue = nil
+}
+
func flushTreeQueue() {
ops := mergeUpsertTrees()
if 1 > len(ops) {