⚡ 改进文档树展开性能 Fix https://github.com/siyuan-note/siyuan/issues/6718
This commit is contained in:
parent
1830cb102e
commit
ceaa2d0f65
2 changed files with 9 additions and 17 deletions
|
@ -29,6 +29,7 @@ require (
|
||||||
github.com/gin-gonic/gin v1.8.1
|
github.com/gin-gonic/gin v1.8.1
|
||||||
github.com/imroc/req/v3 v3.25.0
|
github.com/imroc/req/v3 v3.25.0
|
||||||
github.com/jinzhu/copier v0.3.5
|
github.com/jinzhu/copier v0.3.5
|
||||||
|
github.com/json-iterator/go v1.1.12
|
||||||
github.com/mattn/go-sqlite3 v2.0.3+incompatible
|
github.com/mattn/go-sqlite3 v2.0.3+incompatible
|
||||||
github.com/mitchellh/go-ps v1.0.0
|
github.com/mitchellh/go-ps v1.0.0
|
||||||
github.com/mssola/user_agent v0.5.3
|
github.com/mssola/user_agent v0.5.3
|
||||||
|
@ -86,7 +87,6 @@ require (
|
||||||
github.com/huandu/xstrings v1.3.3 // indirect
|
github.com/huandu/xstrings v1.3.3 // indirect
|
||||||
github.com/imdario/mergo v0.3.13 // indirect
|
github.com/imdario/mergo v0.3.13 // indirect
|
||||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||||
github.com/json-iterator/go v1.1.12 // indirect
|
|
||||||
github.com/juju/errors v1.0.0 // indirect
|
github.com/juju/errors v1.0.0 // indirect
|
||||||
github.com/klauspost/compress v1.15.12 // indirect
|
github.com/klauspost/compress v1.15.12 // indirect
|
||||||
github.com/leodido/go-urn v1.2.1 // indirect
|
github.com/leodido/go-urn v1.2.1 // indirect
|
||||||
|
|
|
@ -37,6 +37,7 @@ import (
|
||||||
"github.com/dustin/go-humanize"
|
"github.com/dustin/go-humanize"
|
||||||
"github.com/facette/natsort"
|
"github.com/facette/natsort"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/siyuan-note/filelock"
|
"github.com/siyuan-note/filelock"
|
||||||
"github.com/siyuan-note/logging"
|
"github.com/siyuan-note/logging"
|
||||||
"github.com/siyuan-note/siyuan/kernel/cache"
|
"github.com/siyuan-note/siyuan/kernel/cache"
|
||||||
|
@ -143,7 +144,7 @@ func (box *Box) docIAL(p string) (ret map[string]string) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
ret = readDocIAL(data)
|
ret = readDocIAL(data)
|
||||||
if nil == ret {
|
if 1 > len(ret) {
|
||||||
logging.LogWarnf("tree [%s] is corrupted", filePath)
|
logging.LogWarnf("tree [%s] is corrupted", filePath)
|
||||||
box.moveCorruptedData(filePath)
|
box.moveCorruptedData(filePath)
|
||||||
return nil
|
return nil
|
||||||
|
@ -167,22 +168,8 @@ func (box *Box) moveCorruptedData(filePath string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func readDocIAL(data []byte) (ret map[string]string) {
|
func readDocIAL(data []byte) (ret map[string]string) {
|
||||||
doc := map[string]interface{}{}
|
|
||||||
if err := gulu.JSON.UnmarshalJSON(data, &doc); nil != err {
|
|
||||||
logging.LogErrorf("unmarshal data failed: %s", err)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
propsArg := doc["Properties"]
|
|
||||||
if nil == propsArg {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
props := propsArg.(map[string]interface{})
|
|
||||||
ret = map[string]string{}
|
ret = map[string]string{}
|
||||||
for k, v := range props {
|
jsoniter.Get(data, "Properties").ToVal(&ret)
|
||||||
ret[k] = v.(string)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,6 +227,11 @@ type FileInfo struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func ListDocTree(boxID, path string, sortMode int) (ret []*File, totals int, err error) {
|
func ListDocTree(boxID, path string, sortMode int) (ret []*File, totals int, err error) {
|
||||||
|
//os.MkdirAll("pprof", 0755)
|
||||||
|
//cpuProfile, _ := os.Create("pprof/cpu_profile_list_doc_tree")
|
||||||
|
//pprof.StartCPUProfile(cpuProfile)
|
||||||
|
//defer pprof.StopCPUProfile()
|
||||||
|
|
||||||
ret = []*File{}
|
ret = []*File{}
|
||||||
|
|
||||||
box := Conf.Box(boxID)
|
box := Conf.Box(boxID)
|
||||||
|
|
Loading…
Add table
Reference in a new issue