🎨 改进内核任务调度机制提升稳定性 https://github.com/siyuan-note/siyuan/issues/7113

This commit is contained in:
Liang Ding 2023-01-26 00:47:14 +08:00
parent c1ff45f4a4
commit 7d1b50116b
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
14 changed files with 51 additions and 52 deletions

View file

@ -497,6 +497,10 @@ func genTreeID(tree *parse.Tree) {
return
}
func ReloadUI() {
task.AppendTask(task.ReloadUI, util.ReloadUI)
}
func FullReindex() {
task.PrependTask(task.DatabaseIndexFull, fullReindex)
task.AppendTask(task.DatabaseIndexRef, IndexRefs)
@ -518,12 +522,6 @@ func fullReindex() {
}
treenode.SaveBlockTree(true)
LoadFlashcards()
util.PushMsg(Conf.Language(58), 7000)
go func() {
time.Sleep(1 * time.Second)
util.ReloadUI()
}()
}
func ChangeBoxSort(boxIDs []string) {

View file

@ -243,6 +243,7 @@ func RollbackDocHistory(boxID, historyPath string) (err error) {
FullReindex()
IncSync()
ReloadUI()
return nil
}
@ -298,6 +299,7 @@ func RollbackNotebookHistory(historyPath string) (err error) {
FullReindex()
IncSync()
ReloadUI()
return nil
}

View file

@ -441,6 +441,7 @@ func ImportData(zipPath string) (err error) {
IncSync()
FullReindex()
ReloadUI()
return
}
@ -706,13 +707,6 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {
return
}
IncSync()
sql.WaitForWritingDatabase()
util.PushEndlessProgress(Conf.Language(58))
go func() {
time.Sleep(2 * time.Second)
util.ReloadUI()
}()
}
debug.FreeOSMemory()
IncSync()

View file

@ -197,16 +197,14 @@ func init() {
// util.SetBootDetails(msg)
// util.ContextPushMsg(context, msg)
//})
eventbus.Subscribe(eventbus.EvtSQLInsertBlocksFTS, func(context map[string]interface{}, current, total, blockCount int, hash string) {
eventbus.Subscribe(eventbus.EvtSQLInsertBlocksFTS, func(context map[string]interface{}, blockCount int, hash string) {
if util.ContainerAndroid == util.Container || util.ContainerIOS == util.Container {
// Android/iOS 端不显示数据索引和搜索索引状态提示 https://github.com/siyuan-note/siyuan/issues/6392
return
}
if (1 > current && 1 == total) || current == total-1 {
current = total
}
current := context["current"]
total := context["total"]
msg := fmt.Sprintf(Conf.Language(90), current, total, blockCount, hash)
util.SetBootDetails(msg)
util.ContextPushMsg(context, msg)

View file

@ -540,6 +540,7 @@ func checkoutRepo(id string) {
}
FullReindex()
ReloadUI()
if syncEnabled {
func() {
@ -1025,12 +1026,15 @@ func syncRepo(exit, byHand bool) (err error) {
cache.ClearDocsIAL() // 同步后文档树文档图标没有更新 https://github.com/siyuan-note/siyuan/issues/4939
if needFullReindex(upsertTrees) { // 改进同步后全量重建索引判断 https://github.com/siyuan-note/siyuan/issues/5764
FullReindex()
if !exit {
ReloadUI()
}
return
}
incReindex(upserts, removes)
incReindex(upserts, removes)
if !exit {
util.ReloadUI()
ReloadUI()
}
elapsed = time.Since(start)

View file

@ -251,11 +251,6 @@ func incReindex(upserts, removes []string) {
treenode.IndexBlockTree(tree)
sql.UpsertTreeQueue(tree)
}
util.PushStatusBar(Conf.Language(58))
if needPushRemoveProgress || needPushUpsertProgress {
util.PushEndlessProgress(Conf.Language(58))
}
}
func SetCloudSyncDir(name string) {