This commit is contained in:
Liang Ding 2023-02-17 22:29:12 +08:00
parent fa1ee8f4a1
commit d5999b26d8
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
3 changed files with 17 additions and 28 deletions

View file

@ -19,7 +19,6 @@ package model
import (
"encoding/json"
"fmt"
"github.com/siyuan-note/eventbus"
"io/fs"
"math"
"os"
@ -571,23 +570,20 @@ func ReindexHistory() (err error) {
return
}
util.PushEndlessProgress(Conf.Language(35))
defer util.PushClearProgress()
util.PushMsg(Conf.Language(35), 7*1000)
sql.InitHistoryDatabase(true)
lutEngine := util.NewLute()
context := map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBarAndProgress}
for _, historyDir := range historyDirs {
if !historyDir.IsDir() {
continue
}
name := historyDir.Name()
indexHistoryDirWithContext(name, lutEngine, context)
indexHistoryDir(name, lutEngine)
}
sql.WaitForWritingHistoryDatabase()
util.ReloadUI()
return
}
@ -600,10 +596,6 @@ const (
)
func indexHistoryDir(name string, luteEngine *lute.Lute) {
indexHistoryDirWithContext(name, luteEngine, map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar})
}
func indexHistoryDirWithContext(name string, luteEngine *lute.Lute, context map[string]interface{}) {
defer logging.Recover()
op := name[strings.LastIndex(name, "-")+1:]
@ -667,7 +659,7 @@ func indexHistoryDirWithContext(name string, luteEngine *lute.Lute, context map[
})
}
sql.IndexHistoriesQueue(histories, context)
sql.IndexHistoriesQueue(histories)
return
}