This commit is contained in:
Daniel 2024-06-20 22:53:27 +08:00
parent 32413fa11c
commit 7a3d4a05ad
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
22 changed files with 453 additions and 497 deletions

View file

@ -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"))))

View file

@ -531,7 +531,6 @@ func fullReindex() {
for _, openedBox := range openedBoxes {
index(openedBox.ID)
}
treenode.SaveBlockTree(true)
LoadFlashcards()
debug.FreeOSMemory()
}

View file

@ -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")

View file

@ -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
}

View file

@ -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)
}

View file

@ -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 {

View file

@ -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)

View file

@ -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
}

View file

@ -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)
}