mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
⚡ 改进数据量较大时的启动速度 https://github.com/siyuan-note/siyuan/issues/6574
This commit is contained in:
parent
b3c9eba73a
commit
cdf2b79678
4 changed files with 39 additions and 8 deletions
|
|
@ -26,11 +26,13 @@ import (
|
|||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/88250/gulu"
|
||||
"github.com/88250/lute/ast"
|
||||
"github.com/88250/lute/parse"
|
||||
"github.com/dustin/go-humanize"
|
||||
"github.com/facette/natsort"
|
||||
"github.com/siyuan-note/filelock"
|
||||
"github.com/siyuan-note/logging"
|
||||
|
|
@ -52,20 +54,29 @@ type Box struct {
|
|||
}
|
||||
|
||||
func AutoStat() {
|
||||
time.Sleep(time.Minute)
|
||||
autoStat()
|
||||
for range time.Tick(10 * time.Minute) {
|
||||
for range time.Tick(2 * time.Hour) {
|
||||
autoStat()
|
||||
}
|
||||
}
|
||||
|
||||
var statLock = sync.Mutex{}
|
||||
|
||||
func autoStat() {
|
||||
statLock.Lock()
|
||||
defer statLock.Unlock()
|
||||
|
||||
Conf.Stat.TreeCount = treenode.CountTrees()
|
||||
Conf.Stat.CTreeCount = treenode.CeilCount(Conf.Stat.TreeCount)
|
||||
Conf.Stat.BlockCount = treenode.CountBlocks()
|
||||
Conf.Stat.CBlockCount = treenode.CeilCount(Conf.Stat.BlockCount)
|
||||
Conf.Stat.DataSize, _ = util.SizeOfDirectory(util.DataDir)
|
||||
Conf.Stat.DataSize, Conf.Stat.AssetsSize = util.DataSize()
|
||||
Conf.Stat.CDataSize = util.CeilSize(Conf.Stat.DataSize)
|
||||
Conf.Stat.CAssetsSize = util.CeilSize(Conf.Stat.AssetsSize)
|
||||
Conf.Save()
|
||||
|
||||
logging.LogInfof("auto stat [trees=%d, blocks=%d, dataSize=%s, assetsSize=%s]", Conf.Stat.TreeCount, Conf.Stat.BlockCount, humanize.Bytes(uint64(Conf.Stat.DataSize)), humanize.Bytes(uint64(Conf.Stat.AssetsSize)))
|
||||
}
|
||||
|
||||
func ListNotebooks() (ret []*Box, err error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue