Skip to content

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

:art: Improve data indexing to reduce disk read operations https://github.com/siyuan-note/siyuan/issues/16958

Danielcc37ec403073
diff --git a/kernel/job/cron.go b/kernel/job/cron.go
index 075c7bc497..36ec7e6da2 100644
--- a/kernel/job/cron.go
+++ b/kernel/job/cron.go
@@ -46,6 +46,7 @@ func StartCron() {
go every(30*time.Second, model.HookDesktopUIProcJob)
go every(24*time.Hour, model.AutoPurgeRepoJob)
go every(30*time.Minute, model.AutoCheckMicrosoftDefenderJob)
+ go every(24*time.Hour, model.ClearOutdatedHistoryDirJob)
// TODO: 移除旧方案 https://github.com/siyuan-note/siyuan/issues/14414 实现新的刷新机制
//go every(3*time.Second, model.WatchLocalShorthands)
diff --git a/kernel/model/history.go b/kernel/model/history.go
index 152a0da00d..b908101b79 100644
--- a/kernel/model/history.go
+++ b/kernel/model/history.go
@@ -77,7 +77,6 @@ func GenerateFileHistory() {
generateAssetsHistory()
historyDir := util.HistoryDir
- clearOutdatedHistoryDir(historyDir)
// 以下部分是老版本的历史数据,不再保留
for _, box := range Conf.GetBoxes() {
@@ -683,7 +682,12 @@ func (box *Box) generateDocHistory0() {
return
}
-func clearOutdatedHistoryDir(historyDir string) {
+func ClearOutdatedHistoryDirJob() {
+ clearOutdatedHistoryDir()
+}
+
+func clearOutdatedHistoryDir() {
+ historyDir := util.HistoryDir
if !gulu.File.IsExist(historyDir) {
return
}