Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
35f7fd0b66
17 changed files with 103 additions and 79 deletions
|
@ -187,6 +187,7 @@ export const transactionError = (data: { code: number, data: string }) => {
|
|||
});
|
||||
btnsElement[1].addEventListener("click", () => {
|
||||
fetchPost("/api/filetree/refreshFiletree", {});
|
||||
dialog.destroy();
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -529,7 +529,7 @@
|
|||
}
|
||||
|
||||
// 用于授权页保持连接,避免非常驻内存内核自动退出 https://github.com/siyuan-note/insider/issues/1099
|
||||
new WebSocket(window.location.protocol === 'https:' ? 'wss' : 'ws' + '://' + window.location.host + '/ws?app=siyuan&id=auth')
|
||||
new WebSocket(`${window.location.protocol === 'https:' ? 'wss' : 'ws'}://${window.location.host}/ws?app=siyuan&id=auth`)
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -174,6 +174,11 @@ func checkBlockExist(c *gin.Context) {
|
|||
ret.Data = id
|
||||
return
|
||||
}
|
||||
if errors.Is(err, model.ErrIndexing) {
|
||||
ret.Code = 3
|
||||
ret.Data = id
|
||||
return
|
||||
}
|
||||
ret.Data = nil != b
|
||||
}
|
||||
|
||||
|
@ -377,6 +382,11 @@ func getBlockInfo(c *gin.Context) {
|
|||
ret.Data = id
|
||||
return
|
||||
}
|
||||
if errors.Is(err, model.ErrIndexing) {
|
||||
ret.Code = 3
|
||||
ret.Data = id
|
||||
return
|
||||
}
|
||||
if nil == block {
|
||||
ret.Code = -1
|
||||
ret.Msg = fmt.Sprintf(model.Conf.Language(15), id)
|
||||
|
@ -403,6 +413,11 @@ func getBlockInfo(c *gin.Context) {
|
|||
ret.Data = id
|
||||
return
|
||||
}
|
||||
if errors.Is(err, model.ErrIndexing) {
|
||||
ret.Code = 3
|
||||
ret.Data = id
|
||||
return
|
||||
}
|
||||
rootTitle := root.IAL["title"]
|
||||
rootTitle = html.UnescapeString(rootTitle)
|
||||
ret.Data = map[string]string{
|
||||
|
|
|
@ -151,7 +151,7 @@ func prepareWriteTree(tree *parse.Tree) (data []byte, filePath string, err error
|
|||
newP := parse.NewParagraph()
|
||||
tree.Root.AppendChild(newP)
|
||||
tree.Root.SetIALAttr("updated", util.TimeFromID(newP.ID))
|
||||
treenode.ReindexBlockTree(tree)
|
||||
treenode.IndexBlockTree(tree)
|
||||
}
|
||||
|
||||
filePath = filepath.Join(util.DataDir, tree.Box, tree.Path)
|
||||
|
|
|
@ -76,8 +76,6 @@ require (
|
|||
github.com/goccy/go-json v0.10.0 // indirect
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
|
||||
github.com/golang/glog v1.0.0 // indirect
|
||||
github.com/golang/mock v1.6.0 // indirect
|
||||
github.com/google/pprof v0.0.0-20230111200839-76d1ae5aea2b // indirect
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
github.com/gopherjs/gopherjs v1.17.2 // indirect
|
||||
github.com/gorilla/context v1.1.1 // indirect
|
||||
|
@ -95,7 +93,6 @@ require (
|
|||
github.com/juju/errors v1.0.0 // indirect
|
||||
github.com/klauspost/compress v1.15.14 // indirect
|
||||
github.com/leodido/go-urn v1.2.1 // indirect
|
||||
github.com/lucas-clemente/quic-go v0.31.1 // indirect
|
||||
github.com/marten-seemann/qpack v0.3.0 // indirect
|
||||
github.com/marten-seemann/qtls-go1-16 v0.1.5 // indirect
|
||||
github.com/marten-seemann/qtls-go1-17 v0.1.2 // indirect
|
||||
|
@ -108,7 +105,7 @@ require (
|
|||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/nxadm/tail v1.4.8 // indirect
|
||||
github.com/onsi/ginkgo v1.16.5 // indirect
|
||||
github.com/onsi/ginkgo/v2 v2.7.0 // indirect
|
||||
github.com/onsi/gomega v1.24.1 // indirect
|
||||
github.com/open-spaced-repetition/go-fsrs v0.1.0 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
|
@ -124,7 +121,6 @@ require (
|
|||
go.uber.org/atomic v1.10.0 // indirect
|
||||
go.uber.org/multierr v1.9.0 // indirect
|
||||
golang.org/x/crypto v0.5.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20230116083435-1de6713980de // indirect
|
||||
golang.org/x/mod v0.7.0 // indirect
|
||||
golang.org/x/net v0.5.0 // indirect
|
||||
golang.org/x/sync v0.1.0 // indirect
|
||||
|
|
|
@ -17,8 +17,6 @@ github.com/88250/go-sqlite3 v1.14.13-0.20220714142610-fbbda1ee84f5 h1:8HdZozCsXS
|
|||
github.com/88250/go-sqlite3 v1.14.13-0.20220714142610-fbbda1ee84f5/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||
github.com/88250/gulu v1.2.3-0.20221117052724-cd06804db798 h1:sR/s/Y9wyl79ZRCUERwLPo9zqaB3KhNRodCMTJ4ozEU=
|
||||
github.com/88250/gulu v1.2.3-0.20221117052724-cd06804db798/go.mod h1:I1qBzsksFL2ciGSuqDE7R3XW4BUMrfDgOvSXEk7FsAI=
|
||||
github.com/88250/lute v1.7.5-0.20230109135528-9a4b82cd4447 h1:AvdRSsM1BC7mdPyigd6IkJbxl+VooZ3N0mxWTTpIR3I=
|
||||
github.com/88250/lute v1.7.5-0.20230109135528-9a4b82cd4447/go.mod h1:cEoBGi0zArPqAsp0MdG9SKinvH/xxZZWXU7sRx8vHSA=
|
||||
github.com/88250/lute v1.7.5 h1:mcPFURh5sK1WH1kFRjqK5DkMWOfVN2BhyrXitN8GmpQ=
|
||||
github.com/88250/lute v1.7.5/go.mod h1:cEoBGi0zArPqAsp0MdG9SKinvH/xxZZWXU7sRx8vHSA=
|
||||
github.com/88250/pdfcpu v0.3.13 h1:touMWMZkCGalMIbEg9bxYp7rETM+zwb9hXjwhqi4I7Q=
|
||||
|
@ -172,8 +170,6 @@ github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO
|
|||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||
github.com/google/pprof v0.0.0-20230111200839-76d1ae5aea2b h1:8htHrh2bw9c7Idkb7YNac+ZpTqLMjRpI+FWu51ltaQc=
|
||||
github.com/google/pprof v0.0.0-20230111200839-76d1ae5aea2b/go.mod h1:dDKJzRmX4S37WGHujM7tX//fmj1uioxKzKxz3lo4HJo=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
|
@ -211,8 +207,6 @@ github.com/huandu/xstrings v1.4.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq
|
|||
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
|
||||
github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
|
||||
github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg=
|
||||
github.com/imroc/req/v3 v3.29.0 h1:QES7vJ7pE6AJWDJtntk81v299PUgcMY0XxcrP4Drmt4=
|
||||
github.com/imroc/req/v3 v3.29.0/go.mod h1:u+HHE8MLYi6SkkfMKb09lvmQdJwUf4wfnVGoEsj8Xtk=
|
||||
github.com/imroc/req/v3 v3.30.0 h1:4iSXgIQfh/3N7JK9Lt7S0q3n/ZvuGICYwV3iv/MWY1M=
|
||||
github.com/imroc/req/v3 v3.30.0/go.mod h1:DKtNwSxMdpqZKJ6neBw8VwRioq78uwmQB4ynQEXNNUk=
|
||||
github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU=
|
||||
|
@ -250,9 +244,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
|||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
|
||||
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
|
||||
github.com/lucas-clemente/quic-go v0.28.1/go.mod h1:oGz5DKK41cJt5+773+BSO9BXDsREY4HLf7+0odGAPO0=
|
||||
github.com/lucas-clemente/quic-go v0.31.1 h1:O8Od7hfioqq0PMYHDyBkxU2aA7iZ2W9pjbrWuja2YR4=
|
||||
github.com/lucas-clemente/quic-go v0.31.1/go.mod h1:0wFbizLgYzqHqtlyxyCaJKlE7bYgE6JQ+54TLd/Dq2g=
|
||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
|
||||
github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI=
|
||||
github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
|
@ -263,11 +254,9 @@ github.com/marten-seemann/qtls-go1-16 v0.1.5 h1:o9JrYPPco/Nukd/HpOHMHZoBDXQqoNtU
|
|||
github.com/marten-seemann/qtls-go1-16 v0.1.5/go.mod h1:gNpI2Ol+lRS3WwSOtIUUtRwZEQMXjYK+dQSBFbethAk=
|
||||
github.com/marten-seemann/qtls-go1-17 v0.1.2 h1:JADBlm0LYiVbuSySCHeY863dNkcpMmDR7s0bLKJeYlQ=
|
||||
github.com/marten-seemann/qtls-go1-17 v0.1.2/go.mod h1:C2ekUKcDdz9SDWxec1N/MvcXBpaX9l3Nx67XaR84L5s=
|
||||
github.com/marten-seemann/qtls-go1-18 v0.1.2/go.mod h1:mJttiymBAByA49mhlNZZGrH5u1uXYZJ+RW28Py7f4m4=
|
||||
github.com/marten-seemann/qtls-go1-18 v0.1.3/go.mod h1:mJttiymBAByA49mhlNZZGrH5u1uXYZJ+RW28Py7f4m4=
|
||||
github.com/marten-seemann/qtls-go1-18 v0.1.4 h1:ogomB+lWV3Vmwiu6RTwDVTMGx+9j7SEi98e8QB35Its=
|
||||
github.com/marten-seemann/qtls-go1-18 v0.1.4/go.mod h1:mJttiymBAByA49mhlNZZGrH5u1uXYZJ+RW28Py7f4m4=
|
||||
github.com/marten-seemann/qtls-go1-19 v0.1.0-beta.1/go.mod h1:5HTDWtVudo/WFsHKRNuOhWlbdjrfs5JHrYb0wIJqGpI=
|
||||
github.com/marten-seemann/qtls-go1-19 v0.1.1/go.mod h1:5HTDWtVudo/WFsHKRNuOhWlbdjrfs5JHrYb0wIJqGpI=
|
||||
github.com/marten-seemann/qtls-go1-19 v0.1.2 h1:ZevAEqKXH0bZmoOBPiqX2h5rhQ7cbZi+X+rlq2JUbCE=
|
||||
github.com/marten-seemann/qtls-go1-19 v0.1.2/go.mod h1:5HTDWtVudo/WFsHKRNuOhWlbdjrfs5JHrYb0wIJqGpI=
|
||||
|
@ -304,15 +293,14 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W
|
|||
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||
github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
|
||||
github.com/onsi/ginkgo v1.16.2/go.mod h1:CObGmKUOKaSC0RjmoAK7tKyn4Azo5P2IWuoMnvwxz1E=
|
||||
github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
|
||||
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
|
||||
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
|
||||
github.com/onsi/ginkgo/v2 v2.7.0 h1:/XxtEV3I3Eif/HobnVx9YmJgk8ENdRsuUmM+fLCFNow=
|
||||
github.com/onsi/ginkgo/v2 v2.7.0/go.mod h1:yjiuMwPokqY1XauOgju45q3sJt6VzQ/Fict1LFVcsAo=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||
github.com/onsi/gomega v1.13.0/go.mod h1:lRk9szgn8TxENtWd0Tp4c3wjlRfMTMH27I+3Je41yGY=
|
||||
github.com/onsi/gomega v1.24.1 h1:KORJXNNTzJXzu4ScJWssJfJMnJ+2QJqhoQSRwNlze9E=
|
||||
github.com/onsi/gomega v1.24.1/go.mod h1:3AOiACssS3/MajrniINInwbfOOtfZvplPzuRSmvt1jM=
|
||||
github.com/open-spaced-repetition/go-fsrs v0.1.0 h1:6H1nCuxuR9p/GmKji0zET1uT5KDwOmW++k7jgr8L0Gk=
|
||||
github.com/open-spaced-repetition/go-fsrs v0.1.0/go.mod h1:H07GOB0A1OBeu3401x8qWKGaa43QjfrDoWy9nba7QCc=
|
||||
github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8=
|
||||
|
@ -383,10 +371,6 @@ 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-20230107020403-092626cc8fed h1:yUHKELxCy4zh6SLVw9wBEYoxRY4rHbd5N0Lcag9qj3M=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20230107020403-092626cc8fed/go.mod h1:k9X5g05t+d5eS1o7PhuZCmGJyyNL/7pb6xiqMoEKEEo=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20230116083837-b4badace9af1 h1:GQVKsYf49LmxMfXI7QYdJxGYNqPVHV43TEMiR10k7HM=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20230116083837-b4badace9af1/go.mod h1:5LbmFNnDo8TZZZcu+vkeW/Gi+yBdVn0v64x0ztoqyfg=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20230117131301-821aa3adc1e7 h1:rlsamJZ3a7kKGQIKS650vkkw9uexpbCzGiyHr/Nkxls=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20230117131301-821aa3adc1e7/go.mod h1:5LbmFNnDo8TZZZcu+vkeW/Gi+yBdVn0v64x0ztoqyfg=
|
||||
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75 h1:Bi7/7f29LW+Fm0cHc0J1NO1cZqyJwljSWVmfOqVZgaE=
|
||||
|
@ -395,8 +379,6 @@ github.com/siyuan-note/eventbus v0.0.0-20220916025349-3ac6e75522da h1:/jNhl7LC+9
|
|||
github.com/siyuan-note/eventbus v0.0.0-20220916025349-3ac6e75522da/go.mod h1:Sqo4FYX5lAXu7gWkbEdJF0e6P57tNNVV4WDKYDctokI=
|
||||
github.com/siyuan-note/filelock v0.0.0-20221117095924-e1947438a35e h1:i3RKrdrddr4AuaHJtoWYAEVNuR7Y9wIsEqPmuFFbJC4=
|
||||
github.com/siyuan-note/filelock v0.0.0-20221117095924-e1947438a35e/go.mod h1:NmpSIVtIGy8eNWapjDIiiCw5+5r5wxC76k40oG+WRXQ=
|
||||
github.com/siyuan-note/httpclient v0.0.0-20230107020227-d12d9c7d13e5 h1:rLMuTLwYLPHGyQdeinVyZdtiHp+aMBTaZxOM40RAJ7s=
|
||||
github.com/siyuan-note/httpclient v0.0.0-20230107020227-d12d9c7d13e5/go.mod h1:tB4/csNIf0gyxXTH+I5rQePH/aZgxXaDlJpdfPf+hg4=
|
||||
github.com/siyuan-note/httpclient v0.0.0-20230116125720-ee36ddf6f223 h1:hG+gucj92x4Dl4lIe2G0WkPgBdlEBnnQCmYpghHeW54=
|
||||
github.com/siyuan-note/httpclient v0.0.0-20230116125720-ee36ddf6f223/go.mod h1:tB4/csNIf0gyxXTH+I5rQePH/aZgxXaDlJpdfPf+hg4=
|
||||
github.com/siyuan-note/logging v0.0.0-20221031125421-9b7234d79d8a h1:b9VJCE8IccYjsadwNBI11he+Wn25hI9lCma4uYoIYEM=
|
||||
|
@ -470,16 +452,11 @@ golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5y
|
|||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
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.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
|
||||
golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE=
|
||||
golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU=
|
||||
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-20230113213754-f9f960f08ad4 h1:CNkDRtCj8otM5CFz5jYvbr8ioXX8flVsLfDWEj0M5kk=
|
||||
golang.org/x/exp v0.0.0-20230113213754-f9f960f08ad4/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
|
||||
golang.org/x/exp v0.0.0-20230116083435-1de6713980de h1:DBWn//IJw30uYCgERoxCg84hWtA97F4wMiKOIh00Uf0=
|
||||
golang.org/x/exp v0.0.0-20230116083435-1de6713980de/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=
|
||||
|
@ -583,7 +560,6 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn
|
|||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
|
||||
golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ=
|
||||
golang.org/x/text v0.0.0-20180302201248-b7ef84aaf62a/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
|
|
|
@ -535,7 +535,7 @@ func RenameAsset(oldPath, newName string) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
treenode.ReindexBlockTree(tree)
|
||||
treenode.IndexBlockTree(tree)
|
||||
sql.UpsertTreeQueue(tree)
|
||||
|
||||
util.PushEndlessProgress(fmt.Sprintf(Conf.Language(111), tree.Root.IALAttr("title")))
|
||||
|
|
|
@ -197,12 +197,12 @@ func SwapBlockRef(refID, defID string, includeChildren bool) (err error) {
|
|||
}
|
||||
refPivot.Unlink()
|
||||
|
||||
treenode.ReindexBlockTree(refTree)
|
||||
treenode.IndexBlockTree(refTree)
|
||||
if err = writeJSONQueue(refTree); nil != err {
|
||||
return
|
||||
}
|
||||
if !sameTree {
|
||||
treenode.ReindexBlockTree(defTree)
|
||||
treenode.IndexBlockTree(defTree)
|
||||
if err = writeJSONQueue(defTree); nil != err {
|
||||
return
|
||||
}
|
||||
|
@ -391,10 +391,11 @@ func getBlock(id string) (ret *Block, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
waitForIndexing()
|
||||
|
||||
tree, err := loadTreeByBlockID(id)
|
||||
if nil != err {
|
||||
if indexing {
|
||||
err = ErrIndexing
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -874,12 +874,12 @@ func writeJSONQueueWithoutChangeTime(tree *parse.Tree) (err error) {
|
|||
}
|
||||
|
||||
func indexWriteJSONQueue(tree *parse.Tree) (err error) {
|
||||
treenode.ReindexBlockTree(tree)
|
||||
treenode.IndexBlockTree(tree)
|
||||
return writeJSONQueue(tree)
|
||||
}
|
||||
|
||||
func indexWriteJSONQueueWithoutChangeTime(tree *parse.Tree) (err error) {
|
||||
treenode.ReindexBlockTree(tree)
|
||||
treenode.IndexBlockTree(tree)
|
||||
return writeJSONQueueWithoutChangeTime(tree)
|
||||
}
|
||||
|
||||
|
@ -888,7 +888,7 @@ func renameWriteJSONQueue(tree *parse.Tree, oldHPath string) (err error) {
|
|||
return
|
||||
}
|
||||
sql.RenameTreeQueue(tree, oldHPath)
|
||||
treenode.ReindexBlockTree(tree)
|
||||
treenode.IndexBlockTree(tree)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -393,7 +393,7 @@ func ImportSY(zipPath, boxID, toPath string) (err error) {
|
|||
continue
|
||||
}
|
||||
|
||||
treenode.ReindexBlockTree(tree)
|
||||
treenode.IndexBlockTree(tree)
|
||||
sql.UpsertTreeQueue(tree)
|
||||
}
|
||||
|
||||
|
|
|
@ -18,18 +18,21 @@ package model
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/siyuan-note/siyuan/kernel/task"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/88250/lute/parse"
|
||||
"github.com/dustin/go-humanize"
|
||||
"github.com/emirpasic/gods/sets/hashset"
|
||||
"github.com/panjf2000/ants/v2"
|
||||
"github.com/siyuan-note/eventbus"
|
||||
"github.com/siyuan-note/logging"
|
||||
"github.com/siyuan-note/siyuan/kernel/cache"
|
||||
"github.com/siyuan-note/siyuan/kernel/filesys"
|
||||
"github.com/siyuan-note/siyuan/kernel/sql"
|
||||
"github.com/siyuan-note/siyuan/kernel/task"
|
||||
"github.com/siyuan-note/siyuan/kernel/treenode"
|
||||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
@ -82,15 +85,20 @@ func index(boxID string) {
|
|||
var treeSize int64
|
||||
i := 0
|
||||
util.PushStatusBar(fmt.Sprintf("["+box.Name+"] "+Conf.Language(64), len(files)))
|
||||
for _, file := range files {
|
||||
if file.isdir || !strings.HasSuffix(file.name, ".sy") {
|
||||
continue
|
||||
}
|
||||
|
||||
poolSize := runtime.NumCPU()
|
||||
if 4 < poolSize {
|
||||
poolSize = 4
|
||||
}
|
||||
waitGroup := &sync.WaitGroup{}
|
||||
p, _ := ants.NewPoolWithFunc(poolSize, func(arg interface{}) {
|
||||
defer waitGroup.Done()
|
||||
|
||||
file := arg.(*FileInfo)
|
||||
tree, err := filesys.LoadTree(box.ID, file.path, luteEngine)
|
||||
if nil != err {
|
||||
logging.LogErrorf("read box [%s] tree [%s] failed: %s", box.ID, file.path, err)
|
||||
continue
|
||||
return
|
||||
}
|
||||
|
||||
docIAL := parse.IAL2MapUnEsc(tree.Root.KramdownIAL)
|
||||
|
@ -104,7 +112,7 @@ func index(boxID string) {
|
|||
}
|
||||
|
||||
cache.PutDocIAL(file.path, docIAL)
|
||||
treenode.ReindexBlockTree(tree)
|
||||
treenode.IndexBlockTree(tree)
|
||||
sql.IndexTreeQueue(box.ID, file.path)
|
||||
|
||||
util.IncBootProgress(bootProgressPart, fmt.Sprintf(Conf.Language(92), util.ShortPathForBootingDisplay(tree.Path)))
|
||||
|
@ -114,7 +122,17 @@ func index(boxID string) {
|
|||
util.PushStatusBar(fmt.Sprintf(Conf.Language(88), i, len(files)-i))
|
||||
}
|
||||
i++
|
||||
})
|
||||
for _, file := range files {
|
||||
if file.isdir || !strings.HasSuffix(file.name, ".sy") {
|
||||
continue
|
||||
}
|
||||
|
||||
waitGroup.Add(1)
|
||||
p.Invoke(file)
|
||||
}
|
||||
waitGroup.Wait()
|
||||
p.Release()
|
||||
|
||||
box.UpdateHistoryGenerated() // 初始化历史生成时间为当前时间
|
||||
end := time.Now()
|
||||
|
|
|
@ -253,7 +253,7 @@ func incReindex(upserts, removes []string) {
|
|||
if nil != err0 {
|
||||
continue
|
||||
}
|
||||
treenode.ReindexBlockTree(tree)
|
||||
treenode.IndexBlockTree(tree)
|
||||
sql.UpsertTreeQueue(tree)
|
||||
}
|
||||
|
||||
|
|
|
@ -1093,7 +1093,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.ReindexBlockTree(tree)
|
||||
treenode.IndexBlockTree(tree)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1446,8 +1446,11 @@ func reindexTree0(tree *parse.Tree, i, size int) {
|
|||
tree.Root.SetIALAttr("updated", updated)
|
||||
indexWriteJSONQueue(tree)
|
||||
} else {
|
||||
treenode.ReindexBlockTree(tree)
|
||||
treenode.IndexBlockTree(tree)
|
||||
sql.IndexTreeQueue(tree.Box, tree.Path)
|
||||
}
|
||||
util.PushStatusBar(fmt.Sprintf(Conf.Language(183), i, size, html.EscapeHTMLStr(path.Base(tree.HPath))))
|
||||
|
||||
if 0 == i%64 {
|
||||
util.PushStatusBar(fmt.Sprintf(Conf.Language(183), i, size, html.EscapeHTMLStr(path.Base(tree.HPath))))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -138,9 +138,12 @@ func loadTree(localPath string, luteEngine *lute.Lute) (ret *parse.Tree, err err
|
|||
return
|
||||
}
|
||||
|
||||
var ErrBoxNotFound = errors.New("notebook not found")
|
||||
var ErrBlockNotFound = errors.New("block not found")
|
||||
var ErrTreeNotFound = errors.New("tree not found")
|
||||
var (
|
||||
ErrBoxNotFound = errors.New("notebook not found")
|
||||
ErrBlockNotFound = errors.New("block not found")
|
||||
ErrTreeNotFound = errors.New("tree not found")
|
||||
ErrIndexing = errors.New("indexing")
|
||||
)
|
||||
|
||||
func loadTreeByBlockID(id string) (ret *parse.Tree, err error) {
|
||||
if "" == id {
|
||||
|
|
|
@ -54,7 +54,7 @@ type dbQueueOperation struct {
|
|||
func AutoFlushTx() {
|
||||
for {
|
||||
time.Sleep(util.SQLFlushInterval)
|
||||
task.PrependTask(task.DatabaseIndexCommit, FlushQueue)
|
||||
task.AppendTask(task.DatabaseIndexCommit, FlushQueue)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ func FlushQueue() {
|
|||
return
|
||||
}
|
||||
|
||||
if 0 < i && 0 == execOps%64 {
|
||||
if 0 < i && 0 == execOps%128 {
|
||||
if err = commitTx(tx); nil != err {
|
||||
logging.LogErrorf("commit tx failed: %s", err)
|
||||
return
|
||||
|
|
|
@ -52,6 +52,7 @@ func PrependTask(action string, handler interface{}, args ...interface{}) {
|
|||
return
|
||||
}
|
||||
|
||||
cancelTask(action, args...)
|
||||
taskQueue = append([]*Task{newTask(action, handler, args...)}, taskQueue...)
|
||||
}
|
||||
|
||||
|
@ -64,20 +65,26 @@ func AppendTask(action string, handler interface{}, args ...interface{}) {
|
|||
return
|
||||
}
|
||||
|
||||
cancelTask(action, args...)
|
||||
taskQueue = append(taskQueue, newTask(action, handler, args...))
|
||||
}
|
||||
|
||||
func CancelTask(actions ...string) {
|
||||
queueLock.Lock()
|
||||
defer queueLock.Unlock()
|
||||
|
||||
func cancelTask(action string, args ...interface{}) {
|
||||
for i := len(taskQueue) - 1; i >= 0; i-- {
|
||||
task := taskQueue[i]
|
||||
for _, action := range actions {
|
||||
if action == task.Action {
|
||||
taskQueue = append(taskQueue[:i], taskQueue[i+1:]...)
|
||||
break
|
||||
if action == task.Action {
|
||||
if len(task.Args) != len(args) {
|
||||
continue
|
||||
}
|
||||
|
||||
for j, arg := range args {
|
||||
if arg != task.Args[j] {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
taskQueue = append(taskQueue[:i], taskQueue[i+1:]...)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ import (
|
|||
|
||||
var blockTrees = map[string]*BlockTree{}
|
||||
var blockTreesLock = sync.Mutex{}
|
||||
var blockTreesChanged = false
|
||||
var blockTreesChanged = time.Time{}
|
||||
|
||||
type BlockTree struct {
|
||||
ID string // 块 ID
|
||||
|
@ -45,6 +45,7 @@ type BlockTree struct {
|
|||
Path string // 文档数据路径
|
||||
HPath string // 文档可读路径
|
||||
Updated string // 更新时间
|
||||
Type string // 类型
|
||||
}
|
||||
|
||||
func GetRootUpdated() (ret map[string]string) {
|
||||
|
@ -206,10 +207,10 @@ func SetBlockTreePath(tree *parse.Tree) {
|
|||
|
||||
for _, b := range blockTrees {
|
||||
if b.RootID == tree.ID {
|
||||
b.BoxID, b.Path, b.HPath, b.Updated = tree.Box, tree.Path, tree.HPath, tree.Root.IALAttr("updated")
|
||||
b.BoxID, b.Path, b.HPath, b.Updated, b.Type = tree.Box, tree.Path, tree.HPath, tree.Root.IALAttr("updated"), TypeAbbr(ast.NodeDocument.String())
|
||||
}
|
||||
}
|
||||
blockTreesChanged = true
|
||||
blockTreesChanged = time.Now()
|
||||
}
|
||||
|
||||
func RemoveBlockTreesByRootID(rootID string) {
|
||||
|
@ -226,7 +227,7 @@ func RemoveBlockTreesByRootID(rootID string) {
|
|||
for _, id := range ids {
|
||||
delete(blockTrees, id)
|
||||
}
|
||||
blockTreesChanged = true
|
||||
blockTreesChanged = time.Now()
|
||||
}
|
||||
|
||||
func RemoveBlockTreesByPath(path string) {
|
||||
|
@ -243,7 +244,7 @@ func RemoveBlockTreesByPath(path string) {
|
|||
for _, id := range ids {
|
||||
delete(blockTrees, id)
|
||||
}
|
||||
blockTreesChanged = true
|
||||
blockTreesChanged = time.Now()
|
||||
}
|
||||
|
||||
func RemoveBlockTreesByPathPrefix(pathPrefix string) {
|
||||
|
@ -260,7 +261,7 @@ func RemoveBlockTreesByPathPrefix(pathPrefix string) {
|
|||
for _, id := range ids {
|
||||
delete(blockTrees, id)
|
||||
}
|
||||
blockTreesChanged = true
|
||||
blockTreesChanged = time.Now()
|
||||
}
|
||||
|
||||
func RemoveBlockTreesByBoxID(boxID string) (ids []string) {
|
||||
|
@ -276,7 +277,7 @@ func RemoveBlockTreesByBoxID(boxID string) (ids []string) {
|
|||
for _, id := range ids {
|
||||
delete(blockTrees, id)
|
||||
}
|
||||
blockTreesChanged = true
|
||||
blockTreesChanged = time.Now()
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -285,10 +286,10 @@ func RemoveBlockTree(id string) {
|
|||
defer blockTreesLock.Unlock()
|
||||
|
||||
delete(blockTrees, id)
|
||||
blockTreesChanged = true
|
||||
blockTreesChanged = time.Now()
|
||||
}
|
||||
|
||||
func ReindexBlockTree(tree *parse.Tree) {
|
||||
func IndexBlockTree(tree *parse.Tree) {
|
||||
blockTreesLock.Lock()
|
||||
defer blockTreesLock.Unlock()
|
||||
|
||||
|
@ -303,16 +304,16 @@ func ReindexBlockTree(tree *parse.Tree) {
|
|||
if "" == n.ID {
|
||||
return ast.WalkContinue
|
||||
}
|
||||
blockTrees[n.ID] = &BlockTree{ID: n.ID, ParentID: parentID, RootID: tree.ID, BoxID: tree.Box, Path: tree.Path, HPath: tree.HPath, Updated: tree.Root.IALAttr("updated")}
|
||||
blockTrees[n.ID] = &BlockTree{ID: n.ID, ParentID: parentID, RootID: tree.ID, BoxID: tree.Box, Path: tree.Path, HPath: tree.HPath, Updated: tree.Root.IALAttr("updated"), Type: TypeAbbr(n.Type.String())}
|
||||
return ast.WalkContinue
|
||||
})
|
||||
blockTreesChanged = true
|
||||
blockTreesChanged = time.Now()
|
||||
}
|
||||
|
||||
func AutoFlushBlockTree() {
|
||||
for {
|
||||
SaveBlockTree(false)
|
||||
time.Sleep(7 * time.Second)
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -361,11 +362,14 @@ func InitBlockTree(force bool) {
|
|||
}
|
||||
|
||||
func SaveBlockTree(force bool) {
|
||||
if !force && !blockTreesChanged {
|
||||
if !force && blockTreesChanged.IsZero() {
|
||||
return
|
||||
}
|
||||
|
||||
start := time.Now()
|
||||
if blockTreesChanged.After(start.Add(-7 * time.Second)) {
|
||||
return
|
||||
}
|
||||
|
||||
blockTreesLock.Lock()
|
||||
data, err := msgpack.Marshal(blockTrees)
|
||||
|
@ -387,5 +391,5 @@ func SaveBlockTree(force bool) {
|
|||
logging.LogWarnf("save block tree [size=%s] to [%s], elapsed [%.2fs]", humanize.Bytes(uint64(len(data))), util.BlockTreePath, elapsed)
|
||||
}
|
||||
|
||||
blockTreesChanged = false
|
||||
blockTreesChanged = time.Time{}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue