mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 15:10:12 +01:00
🎨 Improve ignore indexing
This commit is contained in:
parent
8b7be233d9
commit
214840e2f4
2 changed files with 6 additions and 8 deletions
|
|
@ -513,6 +513,7 @@ func fullReindex() {
|
||||||
}
|
}
|
||||||
treenode.InitBlockTree(true)
|
treenode.InitBlockTree(true)
|
||||||
|
|
||||||
|
sql.IndexIgnoreCached = false
|
||||||
openedBoxes := Conf.GetOpenedBoxes()
|
openedBoxes := Conf.GetOpenedBoxes()
|
||||||
for _, openedBox := range openedBoxes {
|
for _, openedBox := range openedBoxes {
|
||||||
index(openedBox.ID)
|
index(openedBox.ID)
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/88250/gulu"
|
"github.com/88250/gulu"
|
||||||
"github.com/88250/lute/parse"
|
"github.com/88250/lute/parse"
|
||||||
|
|
@ -511,7 +510,7 @@ func insertTree0(tx *sql.Tx, tree *parse.Tree, context map[string]interface{},
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
indexIgnoreLastModified int64
|
IndexIgnoreCached bool
|
||||||
indexIgnore []string
|
indexIgnore []string
|
||||||
indexIgnoreLock = sync.Mutex{}
|
indexIgnoreLock = sync.Mutex{}
|
||||||
)
|
)
|
||||||
|
|
@ -519,16 +518,14 @@ var (
|
||||||
func getIndexIgnoreLines() (ret []string) {
|
func getIndexIgnoreLines() (ret []string) {
|
||||||
// Support ignore index https://github.com/siyuan-note/siyuan/issues/9198
|
// Support ignore index https://github.com/siyuan-note/siyuan/issues/9198
|
||||||
|
|
||||||
now := time.Now().UnixMilli()
|
if IndexIgnoreCached {
|
||||||
if now-indexIgnoreLastModified < 30*1000 {
|
|
||||||
return indexIgnore
|
return indexIgnore
|
||||||
}
|
}
|
||||||
|
|
||||||
indexIgnoreLock.Lock()
|
indexIgnoreLock.Lock()
|
||||||
defer indexIgnoreLock.Unlock()
|
defer indexIgnoreLock.Unlock()
|
||||||
|
|
||||||
indexIgnoreLastModified = now
|
IndexIgnoreCached = true
|
||||||
|
|
||||||
indexIgnorePath := filepath.Join(util.DataDir, ".siyuan", "indexignore")
|
indexIgnorePath := filepath.Join(util.DataDir, ".siyuan", "indexignore")
|
||||||
err := os.MkdirAll(filepath.Dir(indexIgnorePath), 0755)
|
err := os.MkdirAll(filepath.Dir(indexIgnorePath), 0755)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue