Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
a2cc5ca0aa
10 changed files with 73 additions and 34 deletions
8
app/src/types/index.d.ts
vendored
8
app/src/types/index.d.ts
vendored
|
@ -405,6 +405,14 @@ declare interface IConfig {
|
|||
virtualRefAlias: boolean
|
||||
virtualRefAnchor: boolean
|
||||
virtualRefDoc: boolean
|
||||
},
|
||||
stat: {
|
||||
treeCount: number
|
||||
cTreeCount: number
|
||||
blockCount: number
|
||||
cBlockCount: number
|
||||
dataSize: number
|
||||
cDataSize: number
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -142,6 +142,9 @@ export const addGA = () => {
|
|||
subscriptionType: -1,
|
||||
syncEnabled: false,
|
||||
syncProvider: -1,
|
||||
cTreeCount: window.siyuan.config.stat.cTreeCount,
|
||||
cBlockCount: window.siyuan.config.stat.cBlockCount,
|
||||
cDataSize: window.siyuan.config.stat.cDataSize,
|
||||
};
|
||||
if (window.siyuan.user) {
|
||||
para.isLoggedIn = true;
|
||||
|
|
|
@ -17,11 +17,14 @@
|
|||
package conf
|
||||
|
||||
type Stat struct {
|
||||
DocCount int `json:"docCount"` // 总文档计数
|
||||
TreeCount int `json:"treeCount"`
|
||||
CTreeCount int `json:"cTreeCount"`
|
||||
BlockCount int `json:"blockCount"`
|
||||
CBlockCount int `json:"cBlockCount"`
|
||||
DataSize int64 `json:"dataSize"`
|
||||
CDataSize int64 `json:"cDataSize"`
|
||||
}
|
||||
|
||||
func NewStat() *Stat {
|
||||
return &Stat{
|
||||
DocCount: 0,
|
||||
}
|
||||
return &Stat{}
|
||||
}
|
||||
|
|
|
@ -36,14 +36,14 @@ require (
|
|||
github.com/panjf2000/ants/v2 v2.6.0
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||
github.com/radovskyb/watcher v1.0.7
|
||||
github.com/siyuan-note/dejavu v0.0.0-20221109135319-2ce1b3b9f80d
|
||||
github.com/siyuan-note/dejavu v0.0.0-20221110114616-4fc7b49bd441
|
||||
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75
|
||||
github.com/siyuan-note/eventbus v0.0.0-20220916025349-3ac6e75522da
|
||||
github.com/siyuan-note/filelock v0.0.0-20221007163134-7e64809023ef
|
||||
github.com/siyuan-note/httpclient v0.0.0-20221019094331-c904ac9be571
|
||||
github.com/siyuan-note/logging v0.0.0-20221031125421-9b7234d79d8a
|
||||
github.com/steambap/captcha v1.4.1
|
||||
github.com/studio-b12/gowebdav v0.0.0-20221102155456-200a600c0272
|
||||
github.com/studio-b12/gowebdav v0.0.0-20221109171924-60ec5ad56012
|
||||
github.com/vmihailenco/msgpack/v5 v5.3.5
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673
|
||||
golang.org/x/image v0.1.0
|
||||
|
@ -58,7 +58,7 @@ require (
|
|||
github.com/alecthomas/chroma v0.10.0 // indirect
|
||||
github.com/andybalholm/cascadia v1.3.1 // indirect
|
||||
github.com/asaskevich/EventBus v0.0.0-20200907212545-49d423059eef // indirect
|
||||
github.com/aws/aws-sdk-go v1.44.133 // indirect
|
||||
github.com/aws/aws-sdk-go v1.44.134 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||
github.com/dlclark/regexp2 v1.7.0 // indirect
|
||||
github.com/dsnet/compress v0.0.1 // indirect
|
||||
|
@ -113,13 +113,13 @@ require (
|
|||
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
|
||||
go.uber.org/atomic v1.10.0 // indirect
|
||||
go.uber.org/multierr v1.8.0 // indirect
|
||||
golang.org/x/crypto v0.1.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20221109134031-9ce248df8de5 // indirect
|
||||
golang.org/x/mod v0.6.0 // indirect
|
||||
golang.org/x/crypto v0.2.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20221109205753-fc8884afc316 // indirect
|
||||
golang.org/x/mod v0.7.0 // indirect
|
||||
golang.org/x/net v0.2.0 // indirect
|
||||
golang.org/x/sync v0.1.0 // indirect
|
||||
golang.org/x/sys v0.2.0 // indirect
|
||||
golang.org/x/tools v0.2.0 // indirect
|
||||
golang.org/x/tools v0.3.0 // indirect
|
||||
google.golang.org/protobuf v1.28.1 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
)
|
||||
|
|
|
@ -46,8 +46,8 @@ github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de h1:FxWPpzIjnTlhP
|
|||
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de/go.mod h1:DCaWoUhZrYW9p1lxo/cm8EmUOOzAPSEZNGF2DK1dJgw=
|
||||
github.com/asaskevich/EventBus v0.0.0-20200907212545-49d423059eef h1:2JGTg6JapxP9/R33ZaagQtAM4EkkSYnIAlOG5EI8gkM=
|
||||
github.com/asaskevich/EventBus v0.0.0-20200907212545-49d423059eef/go.mod h1:JS7hed4L1fj0hXcyEejnW57/7LCetXggd+vwrRnYeII=
|
||||
github.com/aws/aws-sdk-go v1.44.133 h1:+pWxt9nyKc0jf33rORBaQ93KPjYpmIIy3ozVXdJ82Oo=
|
||||
github.com/aws/aws-sdk-go v1.44.133/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
|
||||
github.com/aws/aws-sdk-go v1.44.134 h1:TzFxjVHPPsibtkD7y6KHI4V00rEKg4yzNlMNGy2ZHeg=
|
||||
github.com/aws/aws-sdk-go v1.44.134/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g=
|
||||
github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s=
|
||||
|
@ -359,8 +359,8 @@ github.com/shurcooL/reactions v0.0.0-20181006231557-f2e0b4ca5b82/go.mod h1:TCR1l
|
|||
github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYEDaXHZDBsXlPCDqdhQuJkuw4NOtaxYe3xii4=
|
||||
github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20221109135319-2ce1b3b9f80d h1:M0ohHIbWiklbbu+p4S91CPKgnBDKKS406MSPidzOrnU=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20221109135319-2ce1b3b9f80d/go.mod h1:PiWhnZhdVqhY0FifDg6kXwn75V97Dg3U/nFeD76fBis=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20221110114616-4fc7b49bd441 h1:btkAcFrPQCoL4Z3oCqKUF4TbizyY3wvbG0H7X5DtW2E=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20221110114616-4fc7b49bd441/go.mod h1:PiWhnZhdVqhY0FifDg6kXwn75V97Dg3U/nFeD76fBis=
|
||||
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75 h1:Bi7/7f29LW+Fm0cHc0J1NO1cZqyJwljSWVmfOqVZgaE=
|
||||
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75/go.mod h1:H8fyqqAbp9XreANjeSbc72zEdFfKTXYN34tc1TjZwtw=
|
||||
github.com/siyuan-note/eventbus v0.0.0-20220916025349-3ac6e75522da h1:/jNhl7LC+9BhkWvNxuJDdsNfA/2wvfuj9mqWx4CbV90=
|
||||
|
@ -393,8 +393,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
|||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/studio-b12/gowebdav v0.0.0-20221102155456-200a600c0272 h1:dXbdJSdxf0EnR4SkcsfRNuGCvoEk9lavXbSCFXN2gJc=
|
||||
github.com/studio-b12/gowebdav v0.0.0-20221102155456-200a600c0272/go.mod h1:bHA7t77X/QFExdeAnDzK6vKM34kEZAcE1OX4MfiwjkE=
|
||||
github.com/studio-b12/gowebdav v0.0.0-20221109171924-60ec5ad56012 h1:ZC+dlnsjxqrcB68nEFbIEfo4iXsog3Sg8FlXKytAjhY=
|
||||
github.com/studio-b12/gowebdav v0.0.0-20221109171924-60ec5ad56012/go.mod h1:bHA7t77X/QFExdeAnDzK6vKM34kEZAcE1OX4MfiwjkE=
|
||||
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
|
||||
github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M=
|
||||
github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0=
|
||||
|
@ -433,12 +433,12 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y
|
|||
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU=
|
||||
golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
|
||||
golang.org/x/crypto v0.2.0 h1:BRXPfhNivWL5Yq0BGQ39a2sW6t44aODpfxkWjYdzewE=
|
||||
golang.org/x/crypto v0.2.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9tZUw9qufEGTyX1+7lmHxV5q5G4=
|
||||
golang.org/x/exp v0.0.0-20221109134031-9ce248df8de5 h1:pug8He0YPdPwDXZN4B/1sJ/8d4YsZqwVZEzg/Xi5w3Y=
|
||||
golang.org/x/exp v0.0.0-20221109134031-9ce248df8de5/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
|
||||
golang.org/x/exp v0.0.0-20221109205753-fc8884afc316 h1:FedCSp0+vayF11p3wAQndIgu+JTcW2nLp5M+HSefjlM=
|
||||
golang.org/x/exp v0.0.0-20221109205753-fc8884afc316/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.0.0-20190823064033-3a9bac650e44/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
|
@ -455,8 +455,8 @@ golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
|
|||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.6.0 h1:b9gGHsz9/HhJ3HF5DHQytPpuwocVTChQJK3AvoLRD5I=
|
||||
golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI=
|
||||
golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA=
|
||||
golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
|
@ -562,8 +562,8 @@ golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4f
|
|||
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.8-0.20211022200916-316ba0b74098/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.2.0 h1:G6AHpWxTMGY1KyEYoAQ5WTtIekUUvDNjan3ugu60JvE=
|
||||
golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA=
|
||||
golang.org/x/tools v0.3.0 h1:SrNbZl6ECOS1qFzgTdQfWXZM9XBkiA6tkFrH9YSTPHM=
|
||||
golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
|
|
@ -52,13 +52,19 @@ type Box struct {
|
|||
}
|
||||
|
||||
func AutoStat() {
|
||||
autoStat()
|
||||
for range time.Tick(10 * time.Minute) {
|
||||
autoStat()
|
||||
}
|
||||
}
|
||||
|
||||
func autoStat() {
|
||||
Conf.Stat.DocCount = sql.CountAllDoc()
|
||||
Conf.Stat.TreeCount = treenode.CountTrees()
|
||||
Conf.Stat.CTreeCount = treenode.CeilCount(Conf.Stat.TreeCount)
|
||||
Conf.Stat.BlockCount = treenode.CountBlocks()
|
||||
Conf.Stat.BlockCount = treenode.CeilCount(Conf.Stat.BlockCount)
|
||||
Conf.Stat.DataSize, _ = util.SizeOfDirectory(util.DataDir)
|
||||
Conf.Stat.CDataSize = util.CeilSize(Conf.Stat.DataSize)
|
||||
Conf.Save()
|
||||
}
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ func checkDownloadInstallPkg() {
|
|||
return
|
||||
}
|
||||
|
||||
msgId := util.PushMsg(Conf.Language(103), 60*1000*10)
|
||||
msgId := util.PushMsg(Conf.Language(103), 1000*7)
|
||||
succ := false
|
||||
for _, downloadPkgURL := range downloadPkgURLs {
|
||||
err = downloadInstallPkg(downloadPkgURL, checksum)
|
||||
|
|
|
@ -92,10 +92,3 @@ func getStat(key string) (ret string) {
|
|||
row.Scan(&ret)
|
||||
return
|
||||
}
|
||||
|
||||
func CountAllDoc() (ret int) {
|
||||
sqlStmt := "SELECT COUNT(*) FROM blocks WHERE type = 'd'"
|
||||
row := queryRow(sqlStmt)
|
||||
row.Scan(&ret)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -71,6 +71,19 @@ func CountBlocks() (ret int) {
|
|||
return len(blockTrees)
|
||||
}
|
||||
|
||||
func CeilCount(count int) int {
|
||||
if 100 > count {
|
||||
return 100
|
||||
}
|
||||
|
||||
for i := 1; i < 40; i++ {
|
||||
if count < i*500 {
|
||||
return i * 500
|
||||
}
|
||||
}
|
||||
return 500*40 + 1
|
||||
}
|
||||
|
||||
func GetBlockTreeRootByPath(boxID, path string) *BlockTree {
|
||||
blockTreesLock.Lock()
|
||||
defer blockTreesLock.Unlock()
|
||||
|
|
|
@ -209,6 +209,19 @@ func SizeOfDirectory(path string) (size int64, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func CeilSize(size int64) int64 {
|
||||
if 100*1024*1024 > size {
|
||||
return 100 * 1024 * 1024
|
||||
}
|
||||
|
||||
for i := int64(1); i < 40; i++ {
|
||||
if 1024*1024*200*i > size {
|
||||
return 1024 * 1024 * int64(i)
|
||||
}
|
||||
}
|
||||
return 1024*1024*200*40 + 1
|
||||
}
|
||||
|
||||
func IsReservedFilename(baseName string) bool {
|
||||
return "assets" == baseName || "templates" == baseName || "widgets" == baseName || "emojis" == baseName || ".siyuan" == baseName || strings.HasPrefix(baseName, ".")
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue