Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
e0ac469cd5
7 changed files with 47 additions and 38 deletions
|
@ -69,21 +69,21 @@ func NewSearch() *Search {
|
|||
return &Search{
|
||||
Document: true,
|
||||
Heading: true,
|
||||
List: true,
|
||||
ListItem: true,
|
||||
List: false,
|
||||
ListItem: false,
|
||||
CodeBlock: true,
|
||||
MathBlock: true,
|
||||
Table: true,
|
||||
Blockquote: true,
|
||||
SuperBlock: true,
|
||||
Blockquote: false,
|
||||
SuperBlock: false,
|
||||
Paragraph: true,
|
||||
HTMLBlock: true,
|
||||
EmbedBlock: false,
|
||||
DatabaseBlock: true,
|
||||
AudioBlock: true,
|
||||
VideoBlock: true,
|
||||
IFrameBlock: true,
|
||||
WidgetBlock: true,
|
||||
AudioBlock: false,
|
||||
VideoBlock: false,
|
||||
IFrameBlock: false,
|
||||
WidgetBlock: false,
|
||||
|
||||
Limit: 64,
|
||||
CaseSensitive: false,
|
||||
|
|
|
@ -521,12 +521,13 @@ func buildLinkRefs(defRootID string, refs []*sql.Ref, keyword string) (ret []*Bl
|
|||
for parentID, _ := range parentRefParagraphs {
|
||||
paragraphParentIDs = append(paragraphParentIDs, parentID)
|
||||
}
|
||||
paragraphParents := sql.GetBlocks(paragraphParentIDs)
|
||||
sqlParagraphParents := sql.GetBlocks(paragraphParentIDs)
|
||||
paragraphParents := fromSQLBlocks(&sqlParagraphParents, "", 12)
|
||||
|
||||
processedParagraphs := hashset.New()
|
||||
for _, p := range paragraphParents {
|
||||
// 改进标题下方块和列表项子块引用时的反链定位 https://github.com/siyuan-note/siyuan/issues/7484
|
||||
if "i" == p.Type {
|
||||
if "NodeListItem" == p.Type {
|
||||
refBlock := parentRefParagraphs[p.ID]
|
||||
if nil != refBlock && p.FContent == refBlock.Content { // 使用内容判断是否是列表项下第一个子块
|
||||
// 如果是列表项下第一个子块,则后续会通过列表项传递或关联处理,所以这里就不处理这个段落了
|
||||
|
@ -535,7 +536,7 @@ func buildLinkRefs(defRootID string, refs []*sql.Ref, keyword string) (ret []*Bl
|
|||
refsCount--
|
||||
continue
|
||||
}
|
||||
ret = append(ret, fromSQLBlock(p, "", 12))
|
||||
ret = append(ret, p)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,6 @@ import (
|
|||
"github.com/siyuan-note/riff"
|
||||
"github.com/siyuan-note/siyuan/kernel/av"
|
||||
"github.com/siyuan-note/siyuan/kernel/cache"
|
||||
"github.com/siyuan-note/siyuan/kernel/conf"
|
||||
"github.com/siyuan-note/siyuan/kernel/filesys"
|
||||
"github.com/siyuan-note/siyuan/kernel/search"
|
||||
"github.com/siyuan-note/siyuan/kernel/sql"
|
||||
|
@ -762,7 +761,7 @@ func GetDoc(startID, endID, id string, index int, query string, queryTypes map[s
|
|||
childCount += treenode.CountBlockNodes(n)
|
||||
}
|
||||
|
||||
if childCount > Conf.Editor.DynamicLoadBlocks && blockCount > conf.MinDynamicLoadBlocks {
|
||||
if childCount > Conf.Editor.DynamicLoadBlocks {
|
||||
scroll = true
|
||||
return ast.WalkStop
|
||||
}
|
||||
|
|
|
@ -1339,7 +1339,7 @@ func fromSQLBlock(sqlBlock *sql.Block, terms string, beforeLen int) (block *Bloc
|
|||
content, _ = markSearch(content, terms, beforeLen)
|
||||
content = maxContent(content, 5120)
|
||||
markdown := maxContent(sqlBlock.Markdown, 5120)
|
||||
|
||||
fContent := util.EscapeHTML(sqlBlock.FContent) // fContent 会用于和 content 对比,在反链计算时用于判断是否是列表项下第一个子块,所以也需要转义 https://github.com/siyuan-note/siyuan/issues/11001
|
||||
block = &Block{
|
||||
Box: sqlBlock.Box,
|
||||
Path: sqlBlock.Path,
|
||||
|
@ -1351,7 +1351,7 @@ func fromSQLBlock(sqlBlock *sql.Block, terms string, beforeLen int) (block *Bloc
|
|||
Memo: sqlBlock.Memo,
|
||||
Tag: sqlBlock.Tag,
|
||||
Content: content,
|
||||
FContent: sqlBlock.FContent,
|
||||
FContent: fContent,
|
||||
Markdown: markdown,
|
||||
Type: treenode.FromAbbrType(sqlBlock.Type),
|
||||
SubType: sqlBlock.SubType,
|
||||
|
|
|
@ -35,6 +35,7 @@ import (
|
|||
var (
|
||||
operationQueue []*dbQueueOperation
|
||||
dbQueueLock = sync.Mutex{}
|
||||
txLock = sync.Mutex{}
|
||||
)
|
||||
|
||||
type dbQueueOperation struct {
|
||||
|
@ -95,29 +96,30 @@ func ClearQueue() {
|
|||
}
|
||||
|
||||
func FlushQueue() {
|
||||
dbQueueLock.Lock()
|
||||
defer dbQueueLock.Unlock()
|
||||
|
||||
total := len(operationQueue)
|
||||
ops := getOperations()
|
||||
total := len(ops)
|
||||
if 1 > total {
|
||||
return
|
||||
}
|
||||
|
||||
txLock.Lock()
|
||||
defer txLock.Unlock()
|
||||
|
||||
start := time.Now()
|
||||
|
||||
context := map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar}
|
||||
if 512 < total {
|
||||
if 512 < len(ops) {
|
||||
disableCache()
|
||||
defer enableCache()
|
||||
}
|
||||
|
||||
groupOpsTotal := map[string]int{}
|
||||
for _, op := range operationQueue {
|
||||
for _, op := range ops {
|
||||
groupOpsTotal[op.action]++
|
||||
}
|
||||
|
||||
groupOpsCurrent := map[string]int{}
|
||||
for i, op := range operationQueue {
|
||||
for i, op := range ops {
|
||||
if util.IsExiting.Load() {
|
||||
return
|
||||
}
|
||||
|
@ -150,8 +152,6 @@ func FlushQueue() {
|
|||
debug.FreeOSMemory()
|
||||
}
|
||||
|
||||
operationQueue = nil
|
||||
|
||||
elapsed := time.Now().Sub(start).Milliseconds()
|
||||
if 7000 < elapsed {
|
||||
logging.LogInfof("database op tx [%dms]", elapsed)
|
||||
|
@ -418,3 +418,12 @@ func RemoveTreePathQueue(treeBox, treePathPrefix string) {
|
|||
}
|
||||
operationQueue = append(operationQueue, newOp)
|
||||
}
|
||||
|
||||
func getOperations() (ops []*dbQueueOperation) {
|
||||
dbQueueLock.Lock()
|
||||
defer dbQueueLock.Unlock()
|
||||
|
||||
ops = operationQueue
|
||||
operationQueue = nil
|
||||
return
|
||||
}
|
||||
|
|
|
@ -33,8 +33,7 @@ import (
|
|||
var (
|
||||
assetContentOperationQueue []*assetContentDBQueueOperation
|
||||
assetContentDBQueueLock = sync.Mutex{}
|
||||
|
||||
assetContentTxLock = sync.Mutex{}
|
||||
assetContentTxLock = sync.Mutex{}
|
||||
)
|
||||
|
||||
type assetContentDBQueueOperation struct {
|
||||
|
@ -51,7 +50,8 @@ func FlushAssetContentTxJob() {
|
|||
|
||||
func FlushAssetContentQueue() {
|
||||
ops := getAssetContentOperations()
|
||||
if 1 > len(ops) {
|
||||
total := len(ops)
|
||||
if 1 > total {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ func FlushAssetContentQueue() {
|
|||
}
|
||||
}
|
||||
|
||||
if 128 < len(ops) {
|
||||
if 128 < total {
|
||||
debug.FreeOSMemory()
|
||||
}
|
||||
|
||||
|
@ -122,24 +122,24 @@ func execAssetContentOp(op *assetContentDBQueueOperation, tx *sql.Tx, context ma
|
|||
}
|
||||
|
||||
func DeleteAssetContentsByPathQueue(path string) {
|
||||
assetContentTxLock.Lock()
|
||||
defer assetContentTxLock.Unlock()
|
||||
assetContentDBQueueLock.Lock()
|
||||
defer assetContentDBQueueLock.Unlock()
|
||||
|
||||
newOp := &assetContentDBQueueOperation{inQueueTime: time.Now(), action: "deletePath", path: path}
|
||||
assetContentOperationQueue = append(assetContentOperationQueue, newOp)
|
||||
}
|
||||
|
||||
func IndexAssetContentsQueue(assetContents []*AssetContent) {
|
||||
assetContentTxLock.Lock()
|
||||
defer assetContentTxLock.Unlock()
|
||||
assetContentDBQueueLock.Lock()
|
||||
defer assetContentDBQueueLock.Unlock()
|
||||
|
||||
newOp := &assetContentDBQueueOperation{inQueueTime: time.Now(), action: "index", assetContents: assetContents}
|
||||
assetContentOperationQueue = append(assetContentOperationQueue, newOp)
|
||||
}
|
||||
|
||||
func getAssetContentOperations() (ops []*assetContentDBQueueOperation) {
|
||||
assetContentTxLock.Lock()
|
||||
defer assetContentTxLock.Unlock()
|
||||
assetContentDBQueueLock.Lock()
|
||||
defer assetContentDBQueueLock.Unlock()
|
||||
|
||||
ops = assetContentOperationQueue
|
||||
assetContentOperationQueue = nil
|
||||
|
|
|
@ -33,8 +33,7 @@ import (
|
|||
var (
|
||||
historyOperationQueue []*historyDBQueueOperation
|
||||
historyDBQueueLock = sync.Mutex{}
|
||||
|
||||
historyTxLock = sync.Mutex{}
|
||||
historyTxLock = sync.Mutex{}
|
||||
)
|
||||
|
||||
type historyDBQueueOperation struct {
|
||||
|
@ -51,7 +50,8 @@ func FlushHistoryTxJob() {
|
|||
|
||||
func FlushHistoryQueue() {
|
||||
ops := getHistoryOperations()
|
||||
if 1 > len(ops) {
|
||||
total := len(ops)
|
||||
if 1 > total {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ func FlushHistoryQueue() {
|
|||
}
|
||||
}
|
||||
|
||||
if 128 < len(ops) {
|
||||
if 128 < total {
|
||||
debug.FreeOSMemory()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue