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
|
|
@ -17,6 +17,7 @@
|
|||
package util
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
|
@ -194,6 +195,27 @@ func SizeOfDirectory(path string) (size int64, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func DataSize() (dataSize, assetsSize int64) {
|
||||
filepath.Walk(DataDir, func(path string, info os.FileInfo, err error) error {
|
||||
if nil != err {
|
||||
logging.LogErrorf("size of data failed: %s", err)
|
||||
return io.EOF
|
||||
}
|
||||
if !info.IsDir() {
|
||||
s := info.Size()
|
||||
dataSize += s
|
||||
|
||||
if strings.Contains(strings.TrimPrefix(path, DataDir), "assets") {
|
||||
assetsSize += s
|
||||
}
|
||||
} else {
|
||||
dataSize += 4096
|
||||
}
|
||||
return nil
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func CeilSize(size int64) int64 {
|
||||
if 100*1024*1024 > size {
|
||||
return 100 * 1024 * 1024
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue