Skip to content

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

:art: Supports configuring data sync index time-consuming prompts https://github.com/siyuan-note/siyuan/issues/9698

Daniel9dfc35e1ac54
diff --git a/kernel/conf/repo.go b/kernel/conf/repo.go
index 7a4b6f1070..6feffba78c 100644
--- a/kernel/conf/repo.go
+++ b/kernel/conf/repo.go
@@ -24,10 +24,17 @@ import (
type Repo struct {
Key []byte `json:"key"` // AES 密钥
+
+ // 同步索引计时,单位毫秒,超过该时间则提示用户索引性能下降
+ // If the data repo indexing time is greater than 7s, prompt user to purge the data repo https://github.com/siyuan-note/siyuan/issues/9613
+ // Supports configuring data sync index time-consuming prompts https://github.com/siyuan-note/siyuan/issues/9698
+ SyncIndexTiming int64 `json:"syncIndexTiming"`
}
func NewRepo() *Repo {
- return &Repo{}
+ return &Repo{
+ SyncIndexTiming: 7 * 1000,
+ }
}
func (*Repo) GetSaveDir() string {
diff --git a/kernel/model/conf.go b/kernel/model/conf.go
index e2aa417091..1d3f3fd644 100644
--- a/kernel/model/conf.go
+++ b/kernel/model/conf.go
@@ -325,6 +325,15 @@ func InitConf() {
if nil == Conf.Repo {
Conf.Repo = conf.NewRepo()
}
+ if timingEnv := os.Getenv("SIYUAN_SYNC_INDEX_TIMING"); "" != timingEnv {
+ val, err := strconv.Atoi(timingEnv)
+ if nil == err {
+ Conf.Repo.SyncIndexTiming = int64(val)
+ }
+ }
+ if 7000 > Conf.Repo.SyncIndexTiming {
+ Conf.Repo.SyncIndexTiming = 7 * 1000
+ }
if nil == Conf.Search {
Conf.Search = conf.NewSearch()
diff --git a/kernel/model/repository.go b/kernel/model/repository.go
index a283ebea67..bc14ef8a7a 100644
--- a/kernel/model/repository.go
+++ b/kernel/model/repository.go
@@ -1485,8 +1485,7 @@ func indexRepoBeforeCloudSync(repo *dejavu.Repo) (beforeIndex, afterIndex *entit
util.PushStatusBar(fmt.Sprintf(Conf.Language(148), elapsed.Seconds()))
}
- if 7000 < elapsed.Milliseconds() {
- // If the data repo indexing time is greater than 7s, prompt user to purge the data repo https://github.com/siyuan-note/siyuan/issues/9613
+ if Conf.Repo.SyncIndexTiming < elapsed.Milliseconds() {
logging.LogWarnf("index data repo before cloud sync elapsed [%dms]", elapsed.Milliseconds())
if !promotedPurgeDataRepo {
go func() {