mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-11 23:22:33 +01:00
♻️ Improve transaction flush
This commit is contained in:
parent
72d1a059ac
commit
8dd0629b9c
23 changed files with 69 additions and 82 deletions
|
|
@ -504,7 +504,7 @@ func BlocksWordCount(ids []string) (ret *util.BlockStatResult) {
|
|||
}
|
||||
|
||||
func StatTree(id string) (ret *util.BlockStatResult) {
|
||||
WaitForWritingFiles()
|
||||
FlushTxQueue()
|
||||
|
||||
tree, _ := LoadTreeByBlockID(id)
|
||||
if nil == tree {
|
||||
|
|
@ -614,7 +614,7 @@ func GetDoc(startID, endID, id string, index int, query string, queryTypes map[s
|
|||
//pprof.StartCPUProfile(cpuProfile)
|
||||
//defer pprof.StopCPUProfile()
|
||||
|
||||
WaitForWritingFiles() // 写入数据时阻塞,避免获取到的数据不一致
|
||||
FlushTxQueue() // 写入数据时阻塞,避免获取到的数据不一致
|
||||
|
||||
inputIndex := index
|
||||
tree, err := LoadTreeByBlockID(id)
|
||||
|
|
@ -1121,7 +1121,7 @@ func DuplicateDoc(tree *parse.Tree) {
|
|||
|
||||
resetTree(tree, "Duplicated", false)
|
||||
createTreeTx(tree)
|
||||
WaitForWritingFiles()
|
||||
FlushTxQueue()
|
||||
|
||||
// 复制为副本时将该副本块插入到数据库中 https://github.com/siyuan-note/siyuan/issues/11959
|
||||
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||
|
|
@ -1170,7 +1170,7 @@ func CreateDocByMd(boxID, p, title, md string, sorts []string) (tree *parse.Tree
|
|||
return
|
||||
}
|
||||
|
||||
WaitForWritingFiles()
|
||||
FlushTxQueue()
|
||||
ChangeFileTreeSort(box.ID, sorts)
|
||||
return
|
||||
}
|
||||
|
|
@ -1185,7 +1185,7 @@ func CreateWithMarkdown(tags, boxID, hPath, md, parentID, id string, withMath bo
|
|||
return
|
||||
}
|
||||
|
||||
WaitForWritingFiles()
|
||||
FlushTxQueue()
|
||||
luteEngine := util.NewLute()
|
||||
if withMath {
|
||||
luteEngine.SetInlineMath(true)
|
||||
|
|
@ -1206,7 +1206,7 @@ func CreateWithMarkdown(tags, boxID, hPath, md, parentID, id string, withMath bo
|
|||
nameValues["tags"] = tags
|
||||
SetBlockAttrs(retID, nameValues)
|
||||
|
||||
WaitForWritingFiles()
|
||||
FlushTxQueue()
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -1231,7 +1231,7 @@ func CreateDailyNote(boxID string) (p string, existed bool, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
WaitForWritingFiles()
|
||||
FlushTxQueue()
|
||||
|
||||
existRoot := treenode.GetBlockTreeRootByHPath(box.ID, hPath)
|
||||
if nil != existRoot {
|
||||
|
|
@ -1305,7 +1305,7 @@ func CreateDailyNote(boxID string) (p string, existed bool, err error) {
|
|||
}
|
||||
IncSync()
|
||||
|
||||
WaitForWritingFiles()
|
||||
FlushTxQueue()
|
||||
|
||||
tree, err := LoadTreeByBlockID(id)
|
||||
if err != nil {
|
||||
|
|
@ -1451,7 +1451,7 @@ func MoveDocs(fromPaths []string, toBoxID, toPath string, callback interface{})
|
|||
defer util.PushClearProgress()
|
||||
}
|
||||
|
||||
WaitForWritingFiles()
|
||||
FlushTxQueue()
|
||||
luteEngine := util.NewLute()
|
||||
count := 0
|
||||
for fromPath, fromBox := range pathsBoxes {
|
||||
|
|
@ -1635,7 +1635,7 @@ func RemoveDoc(boxID, p string) {
|
|||
return
|
||||
}
|
||||
|
||||
WaitForWritingFiles()
|
||||
FlushTxQueue()
|
||||
luteEngine := util.NewLute()
|
||||
removeDoc(box, p, luteEngine)
|
||||
IncSync()
|
||||
|
|
@ -1648,7 +1648,7 @@ func RemoveDocs(paths []string) {
|
|||
|
||||
paths = util.FilterSelfChildDocs(paths)
|
||||
pathsBoxes := getBoxesByPaths(paths)
|
||||
WaitForWritingFiles()
|
||||
FlushTxQueue()
|
||||
luteEngine := util.NewLute()
|
||||
for p, box := range pathsBoxes {
|
||||
removeDoc(box, p, luteEngine)
|
||||
|
|
@ -1772,7 +1772,7 @@ func RenameDoc(boxID, p, title string) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
WaitForWritingFiles()
|
||||
FlushTxQueue()
|
||||
luteEngine := util.NewLute()
|
||||
tree, err := filesys.LoadTree(box.ID, p, luteEngine)
|
||||
if err != nil {
|
||||
|
|
@ -1928,7 +1928,7 @@ func createDoc(boxID, p, title, dom string) (tree *parse.Tree, err error) {
|
|||
|
||||
transaction := &Transaction{DoOperations: []*Operation{{Action: "create", Data: tree}}}
|
||||
PerformTransactions(&[]*Transaction{transaction})
|
||||
WaitForWritingFiles()
|
||||
FlushTxQueue()
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -2000,7 +2000,7 @@ func ChangeFileTreeSort(boxID string, paths []string) {
|
|||
return
|
||||
}
|
||||
|
||||
WaitForWritingFiles()
|
||||
FlushTxQueue()
|
||||
box := Conf.Box(boxID)
|
||||
sortIDs := map[string]int{}
|
||||
max := 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue