Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2022-08-01 10:20:47 +08:00
commit dc35c167b4
6 changed files with 35 additions and 13 deletions

File diff suppressed because one or more lines are too long

View file

@ -7,7 +7,7 @@ require (
github.com/88250/css v0.1.2
github.com/88250/flock v0.8.2
github.com/88250/gulu v1.2.3-0.20220720144315-065ef35ec583
github.com/88250/lute v1.7.5-0.20220730155250-e88d7943c9fb
github.com/88250/lute v1.7.5-0.20220731154823-742119b1a7ea
github.com/88250/melody v0.0.0-20201115062536-c0b3394adcd1
github.com/88250/pdfcpu v0.3.13
github.com/88250/protyle v0.0.0-20220519012506-0a2c8dc24397

View file

@ -58,8 +58,8 @@ github.com/88250/gulu v1.2.0/go.mod h1:ZhEJ98UjR2y7j2toGj4/b+1rRELcZFQAPq/Yjyin2
github.com/88250/gulu v1.2.3-0.20220720144315-065ef35ec583 h1:FhA/zJemLrbOYJpdMIMBezO5rGigQSdPR1kv+aztHfA=
github.com/88250/gulu v1.2.3-0.20220720144315-065ef35ec583/go.mod h1:I1qBzsksFL2ciGSuqDE7R3XW4BUMrfDgOvSXEk7FsAI=
github.com/88250/lute v1.7.4-0.20220426011157-34c9bfa2e148/go.mod h1:Bdu9LRNjQhtL3TftbtpjIWTwDVAXoS7AD8QsZQPk7zo=
github.com/88250/lute v1.7.5-0.20220730155250-e88d7943c9fb h1:oSGz02xal7nuTRJExhIZk8Br9SUCwv25ydorY02I5m8=
github.com/88250/lute v1.7.5-0.20220730155250-e88d7943c9fb/go.mod h1:Bdu9LRNjQhtL3TftbtpjIWTwDVAXoS7AD8QsZQPk7zo=
github.com/88250/lute v1.7.5-0.20220731154823-742119b1a7ea h1:7Ee2xJG7VXCXfkc/YD1w5c2ZOgbtKhKMe5yOVx9Wlns=
github.com/88250/lute v1.7.5-0.20220731154823-742119b1a7ea/go.mod h1:Bdu9LRNjQhtL3TftbtpjIWTwDVAXoS7AD8QsZQPk7zo=
github.com/88250/melody v0.0.0-20201115062536-c0b3394adcd1 h1:9Cb+iN639vUI2OcIBc+4oGwml9/0J6bL6dWNb8Al+1s=
github.com/88250/melody v0.0.0-20201115062536-c0b3394adcd1/go.mod h1:jH6MMPr8G7AMzaVmWHXZQiB1DKO3giWbcWZ7UoJ1teI=
github.com/88250/pdfcpu v0.3.13 h1:touMWMZkCGalMIbEg9bxYp7rETM+zwb9hXjwhqi4I7Q=

View file

@ -170,6 +170,7 @@ func BuildTreeBacklink(id, keyword, mentionKeyword string, beforeLen int) (boxID
var links []*Block
refs := sql.QueryRefsByDefID(id, true)
refs = removeDuplicatedRefs(refs) // 同一个块中引用多个相同块时反链去重 https://github.com/siyuan-note/siyuan/issues/3317
// 为了减少查询,组装好 IDs 后一次查出
defSQLBlockIDs, refSQLBlockIDs := map[string]bool{}, map[string]bool{}
@ -269,6 +270,22 @@ func BuildTreeBacklink(id, keyword, mentionKeyword string, beforeLen int) (boxID
return
}
func removeDuplicatedRefs(refs []*sql.Ref) (ret []*sql.Ref) {
for _, ref := range refs {
contain := false
for _, r := range ret {
if ref.DefBlockID == r.DefBlockID && ref.BlockID == r.BlockID {
contain = true
break
}
}
if !contain {
ret = append(ret, ref)
}
}
return
}
func buildTreeBackmention(defSQLBlock *sql.Block, refBlocks []*Block, keyword string, excludeBacklinkIDs *hashset.Set, beforeLen int) (ret []*Block) {
ret = []*Block{}

View file

@ -24,6 +24,7 @@ import (
"fmt"
"math"
"os"
"path/filepath"
"strings"
"time"
@ -488,6 +489,7 @@ func syncRepo(boot, exit, byHand bool) (err error) {
return
}
start := time.Now()
indexBeforeSync, err := indexRepoBeforeCloudSync(repo)
if nil != err {
syncDownloadErrCount++
@ -495,7 +497,6 @@ func syncRepo(boot, exit, byHand bool) (err error) {
return
}
start := time.Now()
cloudInfo, err := buildCloudInfo()
if nil != err {
return
@ -637,7 +638,7 @@ func subscribeEvents() {
indexWalkDataCount := 0
eventbus.Subscribe(dejavu.EvtIndexWalkData, func(context map[string]interface{}, path string) {
msg := fmt.Sprintf(Conf.Language(158), path)
msg := fmt.Sprintf(Conf.Language(158), filepath.Base(path))
if 0 == indexWalkDataCount%512 {
util.SetBootDetails(msg)
contextPushMsg(context, msg)
@ -665,7 +666,7 @@ func subscribeEvents() {
})
indexUpsertFileCount := 0
eventbus.Subscribe(dejavu.EvtIndexUpsertFile, func(context map[string]interface{}, path string) {
msg := fmt.Sprintf(Conf.Language(160), path)
msg := fmt.Sprintf(Conf.Language(160), filepath.Base(path))
if 0 == indexUpsertFileCount%128 {
util.SetBootDetails(msg)
contextPushMsg(context, msg)
@ -680,7 +681,7 @@ func subscribeEvents() {
})
coWalkDataCount := 0
eventbus.Subscribe(dejavu.EvtCheckoutWalkData, func(context map[string]interface{}, path string) {
msg := fmt.Sprintf(Conf.Language(161), path)
msg := fmt.Sprintf(Conf.Language(161), filepath.Base(path))
if 0 == coWalkDataCount%512 {
util.SetBootDetails(msg)
contextPushMsg(context, msg)
@ -696,7 +697,7 @@ func subscribeEvents() {
})
coUpsertFileCount := 0
eventbus.Subscribe(dejavu.EvtCheckoutUpsertFile, func(context map[string]interface{}, path string) {
msg := fmt.Sprintf(Conf.Language(162), path)
msg := fmt.Sprintf(Conf.Language(162), filepath.Base(path))
util.IncBootProgress(bootProgressPart, msg)
if 0 == coUpsertFileCount%128 {
contextPushMsg(context, msg)
@ -711,7 +712,7 @@ func subscribeEvents() {
})
coRemoveFileCount := 0
eventbus.Subscribe(dejavu.EvtCheckoutRemoveFile, func(context map[string]interface{}, path string) {
msg := fmt.Sprintf(Conf.Language(163), path)
msg := fmt.Sprintf(Conf.Language(163), filepath.Base(path))
util.IncBootProgress(bootProgressPart, msg)
if 0 == coRemoveFileCount%512 {
contextPushMsg(context, msg)

View file

@ -110,11 +110,15 @@ func Boot() {
go cleanOld()
}
func setBootDetails(details string) {
bootDetails = "v" + Ver + " " + details
}
func SetBootDetails(details string) {
if 100 <= bootProgress {
return
}
bootDetails = details
setBootDetails(details)
}
func IncBootProgress(progress float64, details string) {
@ -122,7 +126,7 @@ func IncBootProgress(progress float64, details string) {
return
}
bootProgress += progress
bootDetails = details
setBootDetails(details)
}
func IsBooted() bool {
@ -138,7 +142,7 @@ func GetBootProgress() float64 {
}
func SetBooted() {
bootDetails = "Finishing boot..."
setBootDetails("Finishing boot...")
bootProgress = 100
logging.LogInfof("kernel booted")
}