mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-02-28 05:32:52 +00:00
🎨 Clean code
This commit is contained in:
@@ -72,18 +72,6 @@ func LoadTrees(ids []string) (ret map[string]*parse.Tree) {
|
||||
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) {
|
||||
waitGroup := sync.WaitGroup{}
|
||||
lock := sync.Mutex{}
|
||||
@@ -119,6 +107,18 @@ func batchLoadTrees(boxIDs, paths []string, luteEngine *lute.Lute) (ret []*parse
|
||||
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) {
|
||||
ret = parseJSON2Tree(boxID, p, data, luteEngine)
|
||||
if nil == ret {
|
||||
|
||||
Reference in New Issue
Block a user