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

This commit is contained in:
Daniel 2023-11-20 21:11:28 +08:00
parent a54dd12533
commit 9dfc35e1ac
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 18 additions and 3 deletions

View file

@ -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 {

View file

@ -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()

View file

@ -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() {