mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-23 18:10:12 +01:00
♻️ Refactor the blocktree storage https://github.com/siyuan-note/siyuan/issues/11773
This commit is contained in:
parent
32413fa11c
commit
7a3d4a05ad
22 changed files with 453 additions and 497 deletions
|
|
@ -825,7 +825,7 @@ func RenameAsset(oldPath, newName string) (err error) {
|
|||
continue
|
||||
}
|
||||
|
||||
treenode.IndexBlockTree(tree)
|
||||
treenode.UpsertBlockTree(tree)
|
||||
sql.UpsertTreeQueue(tree)
|
||||
|
||||
util.PushEndlessProgress(fmt.Sprintf(Conf.Language(111), util.EscapeHTML(tree.Root.IALAttr("title"))))
|
||||
|
|
|
|||
|
|
@ -531,7 +531,6 @@ func fullReindex() {
|
|||
for _, openedBox := range openedBoxes {
|
||||
index(openedBox.ID)
|
||||
}
|
||||
treenode.SaveBlockTree(true)
|
||||
LoadFlashcards()
|
||||
debug.FreeOSMemory()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -627,7 +627,6 @@ func Close(force, setCurrentWorkspace bool, execInstallPkg int) (exitCode int) {
|
|||
|
||||
Conf.Close()
|
||||
sql.CloseDatabase()
|
||||
treenode.SaveBlockTree(false)
|
||||
util.SaveAssetsTexts()
|
||||
clearWorkspaceTemp()
|
||||
clearCorruptedNotebooks()
|
||||
|
|
@ -818,24 +817,7 @@ func (conf *AppConf) language(num int) (ret string) {
|
|||
}
|
||||
|
||||
func InitBoxes() {
|
||||
initialized := false
|
||||
if 1 > treenode.CountBlocks() {
|
||||
if gulu.File.IsExist(util.BlockTreePath) {
|
||||
util.IncBootProgress(20, Conf.Language(91))
|
||||
go func() {
|
||||
for i := 0; i < 40; i++ {
|
||||
util.RandomSleep(50, 100)
|
||||
util.IncBootProgress(1, Conf.Language(91))
|
||||
}
|
||||
}()
|
||||
|
||||
treenode.InitBlockTree(false)
|
||||
initialized = true
|
||||
}
|
||||
} else { // 大于 1 的话说明在同步阶段已经加载过了
|
||||
initialized = true
|
||||
}
|
||||
|
||||
initialized := 0 < treenode.CountBlocks()
|
||||
for _, box := range Conf.GetOpenedBoxes() {
|
||||
box.UpdateHistoryGenerated() // 初始化历史生成时间为当前时间
|
||||
|
||||
|
|
@ -844,10 +826,6 @@ func InitBoxes() {
|
|||
}
|
||||
}
|
||||
|
||||
if !initialized {
|
||||
treenode.SaveBlockTree(true)
|
||||
}
|
||||
|
||||
var dbSize string
|
||||
if dbFile, err := os.Stat(util.DBPath); nil == err {
|
||||
dbSize = humanize.BytesCustomCeil(uint64(dbFile.Size()), 2)
|
||||
|
|
@ -982,7 +960,8 @@ func clearWorkspaceTemp() {
|
|||
os.RemoveAll(filepath.Join(util.TempDir, "import"))
|
||||
os.RemoveAll(filepath.Join(util.TempDir, "repo"))
|
||||
os.RemoveAll(filepath.Join(util.TempDir, "os"))
|
||||
os.RemoveAll(filepath.Join(util.TempDir, "blocktree.msgpack")) // v2.7.2 前旧版的块数数据
|
||||
os.RemoveAll(filepath.Join(util.TempDir, "blocktree.msgpack")) // v2.7.2 前旧版的块树数据
|
||||
os.RemoveAll(filepath.Join(util.TempDir, "blocktree")) // v3.1.0 前旧版的块树数据
|
||||
|
||||
// 退出时自动删除超过 7 天的安装包 https://github.com/siyuan-note/siyuan/issues/6128
|
||||
install := filepath.Join(util.TempDir, "install")
|
||||
|
|
|
|||
|
|
@ -1086,7 +1086,7 @@ func indexWriteTreeIndexQueue(tree *parse.Tree) (err error) {
|
|||
}
|
||||
|
||||
func indexWriteTreeUpsertQueue(tree *parse.Tree) (err error) {
|
||||
treenode.IndexBlockTree(tree)
|
||||
treenode.UpsertBlockTree(tree)
|
||||
return writeTreeUpsertQueue(tree)
|
||||
}
|
||||
|
||||
|
|
@ -1095,7 +1095,7 @@ func renameWriteJSONQueue(tree *parse.Tree) (err error) {
|
|||
return
|
||||
}
|
||||
sql.RenameTreeQueue(tree)
|
||||
treenode.IndexBlockTree(tree)
|
||||
treenode.UpsertBlockTree(tree)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -478,7 +478,7 @@ func reindexTree0(tree *parse.Tree, i, size int) {
|
|||
tree.Root.SetIALAttr("updated", updated)
|
||||
indexWriteTreeUpsertQueue(tree)
|
||||
} else {
|
||||
treenode.IndexBlockTree(tree)
|
||||
treenode.UpsertBlockTree(tree)
|
||||
sql.IndexTreeQueue(tree)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import (
|
|||
"github.com/88250/lute/ast"
|
||||
"github.com/siyuan-note/filelock"
|
||||
"github.com/siyuan-note/logging"
|
||||
"github.com/siyuan-note/siyuan/kernel/treenode"
|
||||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
|
|
@ -247,7 +246,6 @@ func Mount(boxID string) (alreadyMount bool, err error) {
|
|||
box.Index()
|
||||
// 缓存根一级的文档树展开
|
||||
ListDocTree(box.ID, "/", util.SortModeUnassigned, false, false, Conf.FileTree.MaxListCount)
|
||||
treenode.SaveBlockTree(false)
|
||||
util.ClearPushProgress(100)
|
||||
|
||||
if reMountGuide {
|
||||
|
|
|
|||
|
|
@ -352,7 +352,7 @@ func upsertIndexes(upsertFilePaths []string) (upsertRootIDs []string) {
|
|||
if nil != err0 {
|
||||
continue
|
||||
}
|
||||
treenode.IndexBlockTree(tree)
|
||||
treenode.UpsertBlockTree(tree)
|
||||
sql.UpsertTreeQueue(tree)
|
||||
|
||||
bts := treenode.GetBlockTreesByRootID(tree.ID)
|
||||
|
|
|
|||
|
|
@ -1378,7 +1378,7 @@ func (tx *Transaction) loadTree(id string) (ret *parse.Tree, err error) {
|
|||
|
||||
func (tx *Transaction) writeTree(tree *parse.Tree) (err error) {
|
||||
tx.trees[tree.ID] = tree
|
||||
treenode.IndexBlockTree(tree)
|
||||
treenode.UpsertBlockTree(tree)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -274,7 +274,7 @@ func searchTreeInFilesystem(rootID string) {
|
|||
return
|
||||
}
|
||||
|
||||
treenode.IndexBlockTree(tree)
|
||||
treenode.UpsertBlockTree(tree)
|
||||
sql.IndexTreeQueue(tree)
|
||||
logging.LogInfof("reindexed tree by filesystem [rootID=%s]", rootID)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue