♻️ 改进后台任务判断重复
This commit is contained in:
parent
83afeb5a8b
commit
23df378a32
2 changed files with 8 additions and 4 deletions
|
@ -157,7 +157,7 @@ func loadTreeByBlockID(id string) (ret *parse.Tree, err error) {
|
|||
|
||||
bt := treenode.GetBlockTree(id)
|
||||
if nil == bt {
|
||||
if task.ContainIndexTask() {
|
||||
if task.ContainIndexTask(task.DatabaseIndex, task.DatabaseIndexFull) {
|
||||
err = ErrIndexing
|
||||
return
|
||||
}
|
||||
|
|
|
@ -18,12 +18,13 @@ package task
|
|||
|
||||
import (
|
||||
"context"
|
||||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
"reflect"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/88250/gulu"
|
||||
"github.com/siyuan-note/logging"
|
||||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -84,9 +85,12 @@ const (
|
|||
ReloadUI = "task.reload.ui" // 重载 UI
|
||||
)
|
||||
|
||||
func ContainIndexTask() bool {
|
||||
func ContainIndexTask(action string, moreActions ...string) bool {
|
||||
actions := append(moreActions, action)
|
||||
actions = gulu.Str.RemoveDuplicatedElem(actions)
|
||||
|
||||
for _, task := range taskQueue {
|
||||
if DatabaseIndex == task.Action || DatabaseIndexFull == task.Action {
|
||||
if gulu.Str.Contains(task.Action, actions) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue