mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-19 16:10:12 +01:00
🎨 Clean code
This commit is contained in:
parent
4ed38f2f2b
commit
6aed85765e
1 changed files with 12 additions and 12 deletions
|
|
@ -72,18 +72,6 @@ func LoadTrees(ids []string) (ret map[string]*parse.Tree) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadTree(boxID, p string, luteEngine *lute.Lute) (ret *parse.Tree, err error) {
|
|
||||||
filePath := filepath.Join(util.DataDir, boxID, p)
|
|
||||||
data, err := filelock.ReadFile(filePath)
|
|
||||||
if err != nil {
|
|
||||||
logging.LogErrorf("load tree [%s] failed: %s", p, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
ret, err = LoadTreeByData(data, boxID, p, luteEngine)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func batchLoadTrees(boxIDs, paths []string, luteEngine *lute.Lute) (ret []*parse.Tree, errs []error) {
|
func batchLoadTrees(boxIDs, paths []string, luteEngine *lute.Lute) (ret []*parse.Tree, errs []error) {
|
||||||
waitGroup := sync.WaitGroup{}
|
waitGroup := sync.WaitGroup{}
|
||||||
lock := sync.Mutex{}
|
lock := sync.Mutex{}
|
||||||
|
|
@ -119,6 +107,18 @@ func batchLoadTrees(boxIDs, paths []string, luteEngine *lute.Lute) (ret []*parse
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func LoadTree(boxID, p string, luteEngine *lute.Lute) (ret *parse.Tree, err error) {
|
||||||
|
filePath := filepath.Join(util.DataDir, boxID, p)
|
||||||
|
data, err := filelock.ReadFile(filePath)
|
||||||
|
if err != nil {
|
||||||
|
logging.LogErrorf("load tree [%s] failed: %s", p, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ret, err = LoadTreeByData(data, boxID, p, luteEngine)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func LoadTreeByData(data []byte, boxID, p string, luteEngine *lute.Lute) (ret *parse.Tree, err error) {
|
func LoadTreeByData(data []byte, boxID, p string, luteEngine *lute.Lute) (ret *parse.Tree, err error) {
|
||||||
ret = parseJSON2Tree(boxID, p, data, luteEngine)
|
ret = parseJSON2Tree(boxID, p, data, luteEngine)
|
||||||
if nil == ret {
|
if nil == ret {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue