Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2022-11-25 23:06:21 +08:00
commit a8f3b1762a
2 changed files with 9 additions and 17 deletions

View file

@ -29,6 +29,7 @@ require (
github.com/gin-gonic/gin v1.8.1
github.com/imroc/req/v3 v3.25.0
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/mitchellh/go-ps v1.0.0
github.com/mssola/user_agent v0.5.3
@ -86,7 +87,6 @@ require (
github.com/huandu/xstrings v1.3.3 // indirect
github.com/imdario/mergo v0.3.13 // 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/klauspost/compress v1.15.12 // indirect
github.com/leodido/go-urn v1.2.1 // indirect

View file

@ -37,6 +37,7 @@ import (
"github.com/dustin/go-humanize"
"github.com/facette/natsort"
"github.com/gin-gonic/gin"
jsoniter "github.com/json-iterator/go"
"github.com/siyuan-note/filelock"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/cache"
@ -143,7 +144,7 @@ func (box *Box) docIAL(p string) (ret map[string]string) {
return nil
}
ret = readDocIAL(data)
if nil == ret {
if 1 > len(ret) {
logging.LogWarnf("tree [%s] is corrupted", filePath)
box.moveCorruptedData(filePath)
return nil
@ -167,22 +168,8 @@ func (box *Box) moveCorruptedData(filePath 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{}
for k, v := range props {
ret[k] = v.(string)
}
jsoniter.Get(data, "Properties").ToVal(&ret)
return
}
@ -240,6 +227,11 @@ type FileInfo struct {
}
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{}
box := Conf.Box(boxID)