filetree.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  1. // SiYuan - Build Your Eternal Digital Garden
  2. // Copyright (c) 2020-present, b3log.org
  3. //
  4. // This program is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Affero General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Affero General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Affero General Public License
  15. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. package api
  17. import (
  18. "errors"
  19. "fmt"
  20. "net/http"
  21. "path"
  22. "regexp"
  23. "strings"
  24. "unicode/utf8"
  25. "github.com/88250/gulu"
  26. "github.com/gin-gonic/gin"
  27. "github.com/siyuan-note/filelock"
  28. "github.com/siyuan-note/siyuan/kernel/model"
  29. "github.com/siyuan-note/siyuan/kernel/util"
  30. )
  31. func refreshFiletree(c *gin.Context) {
  32. ret := gulu.Ret.NewResult()
  33. defer c.JSON(http.StatusOK, ret)
  34. model.FullReindex()
  35. }
  36. func doc2Heading(c *gin.Context) {
  37. ret := gulu.Ret.NewResult()
  38. defer c.JSON(http.StatusOK, ret)
  39. arg, ok := util.JsonArg(c, ret)
  40. if !ok {
  41. return
  42. }
  43. srcID := arg["srcID"].(string)
  44. targetID := arg["targetID"].(string)
  45. after := arg["after"].(bool)
  46. srcTreeBox, srcTreePath, err := model.Doc2Heading(srcID, targetID, after)
  47. if nil != err {
  48. ret.Code = -1
  49. ret.Msg = err.Error()
  50. ret.Data = map[string]interface{}{"closeTimeout": 5000}
  51. return
  52. }
  53. ret.Data = map[string]interface{}{
  54. "srcTreeBox": srcTreeBox,
  55. "srcTreePath": srcTreePath,
  56. }
  57. }
  58. func heading2Doc(c *gin.Context) {
  59. ret := gulu.Ret.NewResult()
  60. defer c.JSON(http.StatusOK, ret)
  61. arg, ok := util.JsonArg(c, ret)
  62. if !ok {
  63. return
  64. }
  65. srcHeadingID := arg["srcHeadingID"].(string)
  66. targetNotebook := arg["targetNoteBook"].(string)
  67. targetPath := arg["targetPath"].(string)
  68. srcRootBlockID, targetPath, err := model.Heading2Doc(srcHeadingID, targetNotebook, targetPath)
  69. if nil != err {
  70. ret.Code = -1
  71. ret.Msg = err.Error()
  72. ret.Data = map[string]interface{}{"closeTimeout": 5000}
  73. return
  74. }
  75. model.WaitForWritingFiles()
  76. tree, err := model.LoadTree(targetNotebook, targetPath)
  77. if nil != err {
  78. ret.Code = -1
  79. ret.Msg = err.Error()
  80. return
  81. }
  82. name := path.Base(targetPath)
  83. box := model.Conf.Box(targetNotebook)
  84. files, _, _ := model.ListDocTree(targetNotebook, path.Dir(targetPath), model.Conf.FileTree.Sort)
  85. evt := util.NewCmdResult("heading2doc", 0, util.PushModeBroadcast)
  86. evt.Data = map[string]interface{}{
  87. "box": box,
  88. "path": targetPath,
  89. "files": files,
  90. "name": name,
  91. "id": tree.Root.ID,
  92. "srcRootBlockID": srcRootBlockID,
  93. }
  94. evt.Callback = arg["callback"]
  95. util.PushEvent(evt)
  96. }
  97. func li2Doc(c *gin.Context) {
  98. ret := gulu.Ret.NewResult()
  99. defer c.JSON(http.StatusOK, ret)
  100. arg, ok := util.JsonArg(c, ret)
  101. if !ok {
  102. return
  103. }
  104. srcListItemID := arg["srcListItemID"].(string)
  105. targetNotebook := arg["targetNoteBook"].(string)
  106. targetPath := arg["targetPath"].(string)
  107. srcRootBlockID, targetPath, err := model.ListItem2Doc(srcListItemID, targetNotebook, targetPath)
  108. if nil != err {
  109. ret.Code = -1
  110. ret.Msg = err.Error()
  111. ret.Data = map[string]interface{}{"closeTimeout": 5000}
  112. return
  113. }
  114. model.WaitForWritingFiles()
  115. tree, err := model.LoadTree(targetNotebook, targetPath)
  116. if nil != err {
  117. ret.Code = -1
  118. ret.Msg = err.Error()
  119. return
  120. }
  121. name := path.Base(targetPath)
  122. box := model.Conf.Box(targetNotebook)
  123. files, _, _ := model.ListDocTree(targetNotebook, path.Dir(targetPath), model.Conf.FileTree.Sort)
  124. evt := util.NewCmdResult("li2doc", 0, util.PushModeBroadcast)
  125. evt.Data = map[string]interface{}{
  126. "box": box,
  127. "path": targetPath,
  128. "files": files,
  129. "name": name,
  130. "id": tree.Root.ID,
  131. "srcRootBlockID": srcRootBlockID,
  132. }
  133. evt.Callback = arg["callback"]
  134. util.PushEvent(evt)
  135. }
  136. func getHPathByPath(c *gin.Context) {
  137. ret := gulu.Ret.NewResult()
  138. defer c.JSON(http.StatusOK, ret)
  139. arg, ok := util.JsonArg(c, ret)
  140. if !ok {
  141. return
  142. }
  143. notebook := arg["notebook"].(string)
  144. p := arg["path"].(string)
  145. hPath, err := model.GetHPathByPath(notebook, p)
  146. if nil != err {
  147. ret.Code = -1
  148. ret.Msg = err.Error()
  149. return
  150. }
  151. ret.Data = hPath
  152. }
  153. func getHPathsByPaths(c *gin.Context) {
  154. ret := gulu.Ret.NewResult()
  155. defer c.JSON(http.StatusOK, ret)
  156. arg, ok := util.JsonArg(c, ret)
  157. if !ok {
  158. return
  159. }
  160. pathsArg := arg["paths"].([]interface{})
  161. var paths []string
  162. for _, p := range pathsArg {
  163. paths = append(paths, p.(string))
  164. }
  165. hPath, err := model.GetHPathsByPaths(paths)
  166. if nil != err {
  167. ret.Code = -1
  168. ret.Msg = err.Error()
  169. return
  170. }
  171. ret.Data = hPath
  172. }
  173. func getHPathByID(c *gin.Context) {
  174. ret := gulu.Ret.NewResult()
  175. defer c.JSON(http.StatusOK, ret)
  176. arg, ok := util.JsonArg(c, ret)
  177. if !ok {
  178. return
  179. }
  180. id := arg["id"].(string)
  181. hPath, err := model.GetHPathByID(id)
  182. if nil != err {
  183. ret.Code = -1
  184. ret.Msg = err.Error()
  185. return
  186. }
  187. ret.Data = hPath
  188. }
  189. func getFullHPathByID(c *gin.Context) {
  190. ret := gulu.Ret.NewResult()
  191. defer c.JSON(http.StatusOK, ret)
  192. arg, ok := util.JsonArg(c, ret)
  193. if !ok {
  194. return
  195. }
  196. if nil == arg["id"] {
  197. return
  198. }
  199. id := arg["id"].(string)
  200. hPath, err := model.GetFullHPathByID(id)
  201. if nil != err {
  202. ret.Code = -1
  203. ret.Msg = err.Error()
  204. return
  205. }
  206. ret.Data = hPath
  207. }
  208. func moveDocs(c *gin.Context) {
  209. ret := gulu.Ret.NewResult()
  210. defer c.JSON(http.StatusOK, ret)
  211. arg, ok := util.JsonArg(c, ret)
  212. if !ok {
  213. return
  214. }
  215. var fromPaths []string
  216. fromPathsArg := arg["fromPaths"].([]interface{})
  217. for _, fromPath := range fromPathsArg {
  218. fromPaths = append(fromPaths, fromPath.(string))
  219. }
  220. toPath := arg["toPath"].(string)
  221. toNotebook := arg["toNotebook"].(string)
  222. err := model.MoveDocs(fromPaths, toNotebook, toPath)
  223. if nil != err {
  224. ret.Code = -1
  225. ret.Msg = err.Error()
  226. ret.Data = map[string]interface{}{"closeTimeout": 7000}
  227. return
  228. }
  229. }
  230. func removeDoc(c *gin.Context) {
  231. ret := gulu.Ret.NewResult()
  232. defer c.JSON(http.StatusOK, ret)
  233. arg, ok := util.JsonArg(c, ret)
  234. if !ok {
  235. return
  236. }
  237. notebook := arg["notebook"].(string)
  238. p := arg["path"].(string)
  239. model.RemoveDoc(notebook, p)
  240. }
  241. func removeDocs(c *gin.Context) {
  242. ret := gulu.Ret.NewResult()
  243. defer c.JSON(http.StatusOK, ret)
  244. arg, ok := util.JsonArg(c, ret)
  245. if !ok {
  246. return
  247. }
  248. pathsArg := arg["paths"].([]interface{})
  249. var paths []string
  250. for _, path := range pathsArg {
  251. paths = append(paths, path.(string))
  252. }
  253. model.RemoveDocs(paths)
  254. }
  255. func renameDoc(c *gin.Context) {
  256. ret := gulu.Ret.NewResult()
  257. defer c.JSON(http.StatusOK, ret)
  258. arg, ok := util.JsonArg(c, ret)
  259. if !ok {
  260. return
  261. }
  262. notebook := arg["notebook"].(string)
  263. p := arg["path"].(string)
  264. title := arg["title"].(string)
  265. err := model.RenameDoc(notebook, p, title)
  266. if nil != err {
  267. ret.Code = -1
  268. ret.Msg = err.Error()
  269. return
  270. }
  271. return
  272. }
  273. func duplicateDoc(c *gin.Context) {
  274. ret := gulu.Ret.NewResult()
  275. defer c.JSON(http.StatusOK, ret)
  276. arg, ok := util.JsonArg(c, ret)
  277. if !ok {
  278. return
  279. }
  280. id := arg["id"].(string)
  281. newTree, err := model.DuplicateDoc(id)
  282. if nil != err {
  283. ret.Code = -1
  284. ret.Msg = err.Error()
  285. ret.Data = map[string]interface{}{"closeTimeout": 7000}
  286. return
  287. }
  288. block, _ := model.GetBlock(id)
  289. p := block.Path
  290. notebook := block.Box
  291. box := model.Conf.Box(notebook)
  292. tree, err := model.LoadTree(box.ID, p)
  293. if nil != err {
  294. ret.Code = -1
  295. ret.Msg = err.Error()
  296. return
  297. }
  298. pushCreate(box, p, tree.Root.ID, arg)
  299. ret.Data = map[string]interface{}{
  300. "id": newTree.Root.ID,
  301. "notebook": notebook,
  302. "path": newTree.Path,
  303. "hPath": newTree.HPath,
  304. }
  305. }
  306. func createDoc(c *gin.Context) {
  307. ret := gulu.Ret.NewResult()
  308. defer c.JSON(http.StatusOK, ret)
  309. arg, ok := util.JsonArg(c, ret)
  310. if !ok {
  311. return
  312. }
  313. notebook := arg["notebook"].(string)
  314. p := arg["path"].(string)
  315. title := arg["title"].(string)
  316. md := arg["md"].(string)
  317. sortsArg := arg["sorts"]
  318. var sorts []string
  319. if nil != sortsArg {
  320. for _, sort := range sortsArg.([]interface{}) {
  321. sorts = append(sorts, sort.(string))
  322. }
  323. }
  324. err := model.CreateDocByMd(notebook, p, title, md, sorts)
  325. if nil != err {
  326. ret.Code = -1
  327. ret.Msg = err.Error()
  328. ret.Data = map[string]interface{}{"closeTimeout": 7000}
  329. return
  330. }
  331. box := model.Conf.Box(notebook)
  332. tree, err := model.LoadTree(box.ID, p)
  333. if nil != err {
  334. ret.Code = -1
  335. ret.Msg = err.Error()
  336. return
  337. }
  338. pushCreate(box, p, tree.Root.ID, arg)
  339. }
  340. func createDailyNote(c *gin.Context) {
  341. ret := gulu.Ret.NewResult()
  342. defer c.JSON(http.StatusOK, ret)
  343. arg, ok := util.JsonArg(c, ret)
  344. if !ok {
  345. return
  346. }
  347. notebook := arg["notebook"].(string)
  348. p, existed, err := model.CreateDailyNote(notebook)
  349. if nil != err {
  350. if model.ErrBoxNotFound == err {
  351. ret.Code = 1
  352. } else {
  353. ret.Code = -1
  354. }
  355. ret.Msg = err.Error()
  356. return
  357. }
  358. box := model.Conf.Box(notebook)
  359. model.WaitForWritingFiles()
  360. tree, err := model.LoadTree(box.ID, p)
  361. if nil != err {
  362. ret.Code = -1
  363. ret.Msg = err.Error()
  364. return
  365. }
  366. appArg := arg["app"]
  367. app := ""
  368. if nil != appArg {
  369. app = appArg.(string)
  370. }
  371. pushMode := util.PushModeBroadcast
  372. if existed && "" != app {
  373. pushMode = util.PushModeBroadcastApp
  374. }
  375. evt := util.NewCmdResult("createdailynote", 0, pushMode)
  376. evt.AppId = app
  377. name := path.Base(p)
  378. files, _, _ := model.ListDocTree(box.ID, path.Dir(p), model.Conf.FileTree.Sort)
  379. evt.Data = map[string]interface{}{
  380. "box": box,
  381. "path": p,
  382. "files": files,
  383. "name": name,
  384. "id": tree.Root.ID,
  385. }
  386. evt.Callback = arg["callback"]
  387. util.PushEvent(evt)
  388. }
  389. func createDocWithMd(c *gin.Context) {
  390. ret := gulu.Ret.NewResult()
  391. defer c.JSON(http.StatusOK, ret)
  392. arg, ok := util.JsonArg(c, ret)
  393. if !ok {
  394. return
  395. }
  396. notebook := arg["notebook"].(string)
  397. hPath := arg["path"].(string)
  398. markdown := arg["markdown"].(string)
  399. baseName := path.Base(hPath)
  400. dir := path.Dir(hPath)
  401. r, _ := regexp.Compile("\r\n|\r|\n|\u2028|\u2029|\t|/")
  402. baseName = r.ReplaceAllString(baseName, "")
  403. if 512 < utf8.RuneCountInString(baseName) {
  404. baseName = gulu.Str.SubStr(baseName, 512)
  405. }
  406. hPath = path.Join(dir, baseName)
  407. if !strings.HasPrefix(hPath, "/") {
  408. hPath = "/" + hPath
  409. }
  410. id, err := model.CreateWithMarkdown(notebook, hPath, markdown)
  411. if nil != err {
  412. ret.Code = -1
  413. ret.Msg = err.Error()
  414. return
  415. }
  416. ret.Data = id
  417. box := model.Conf.Box(notebook)
  418. b, _ := model.GetBlock(id)
  419. p := b.Path
  420. pushCreate(box, p, id, arg)
  421. }
  422. func lockFile(c *gin.Context) {
  423. ret := gulu.Ret.NewResult()
  424. defer c.JSON(http.StatusOK, ret)
  425. arg, ok := util.JsonArg(c, ret)
  426. if !ok {
  427. return
  428. }
  429. id := arg["id"].(string)
  430. locked := model.TryAccessFileByBlockID(id)
  431. if !locked {
  432. ret.Code = -1
  433. ret.Msg = fmt.Sprintf(model.Conf.Language(75))
  434. ret.Data = map[string]interface{}{"closeTimeout": 5000}
  435. }
  436. }
  437. func getDocNameTemplate(c *gin.Context) {
  438. ret := gulu.Ret.NewResult()
  439. defer c.JSON(http.StatusOK, ret)
  440. arg, ok := util.JsonArg(c, ret)
  441. if !ok {
  442. return
  443. }
  444. notebook := arg["notebook"].(string)
  445. box := model.Conf.Box(notebook)
  446. nameTemplate := model.Conf.FileTree.CreateDocNameTemplate
  447. if nil != box {
  448. nameTemplate = box.GetConf().CreateDocNameTemplate
  449. }
  450. if "" == nameTemplate {
  451. nameTemplate = model.Conf.FileTree.CreateDocNameTemplate
  452. }
  453. name, err := model.RenderGoTemplate(nameTemplate)
  454. if nil != err {
  455. ret.Code = -1
  456. ret.Msg = err.Error()
  457. return
  458. }
  459. ret.Data = map[string]interface{}{
  460. "name": name,
  461. }
  462. }
  463. func getRefCreateSavePath(c *gin.Context) {
  464. ret := gulu.Ret.NewResult()
  465. defer c.JSON(http.StatusOK, ret)
  466. arg, ok := util.JsonArg(c, ret)
  467. if !ok {
  468. return
  469. }
  470. notebook := arg["notebook"].(string)
  471. box := model.Conf.Box(notebook)
  472. refCreateSavePath := model.Conf.FileTree.RefCreateSavePath
  473. if nil != box {
  474. refCreateSavePath = box.GetConf().RefCreateSavePath
  475. }
  476. if "" == refCreateSavePath {
  477. refCreateSavePath = model.Conf.FileTree.RefCreateSavePath
  478. }
  479. p, err := model.RenderGoTemplate(refCreateSavePath)
  480. if nil != err {
  481. ret.Code = -1
  482. ret.Msg = err.Error()
  483. return
  484. }
  485. ret.Data = map[string]interface{}{
  486. "path": p,
  487. }
  488. }
  489. func changeSort(c *gin.Context) {
  490. ret := gulu.Ret.NewResult()
  491. defer c.JSON(http.StatusOK, ret)
  492. arg, ok := util.JsonArg(c, ret)
  493. if !ok {
  494. return
  495. }
  496. notebook := arg["notebook"].(string)
  497. pathsArg := arg["paths"].([]interface{})
  498. var paths []string
  499. for _, p := range pathsArg {
  500. paths = append(paths, p.(string))
  501. }
  502. model.ChangeFileTreeSort(notebook, paths)
  503. }
  504. func searchDocs(c *gin.Context) {
  505. ret := gulu.Ret.NewResult()
  506. defer c.JSON(http.StatusOK, ret)
  507. arg, ok := util.JsonArg(c, ret)
  508. if !ok {
  509. return
  510. }
  511. k := arg["k"].(string)
  512. ret.Data = model.SearchDocsByKeyword(k)
  513. }
  514. func listDocsByPath(c *gin.Context) {
  515. ret := gulu.Ret.NewResult()
  516. defer c.JSON(http.StatusOK, ret)
  517. arg, ok := util.JsonArg(c, ret)
  518. if !ok {
  519. return
  520. }
  521. notebook := arg["notebook"].(string)
  522. p := arg["path"].(string)
  523. sortParam := arg["sort"]
  524. sortMode := model.Conf.FileTree.Sort
  525. if nil != sortParam {
  526. sortMode = int(sortParam.(float64))
  527. }
  528. files, totals, err := model.ListDocTree(notebook, p, sortMode)
  529. if nil != err {
  530. ret.Code = -1
  531. ret.Msg = err.Error()
  532. return
  533. }
  534. if model.Conf.FileTree.MaxListCount < totals {
  535. util.PushMsg(fmt.Sprintf(model.Conf.Language(48), len(files)), 7000)
  536. }
  537. ret.Data = map[string]interface{}{
  538. "box": notebook,
  539. "path": p,
  540. "files": files,
  541. }
  542. // 持久化文档面板排序
  543. model.Conf.FileTree.Sort = sortMode
  544. model.Conf.Save()
  545. }
  546. func getDoc(c *gin.Context) {
  547. ret := gulu.Ret.NewResult()
  548. defer c.JSON(http.StatusOK, ret)
  549. arg, ok := util.JsonArg(c, ret)
  550. if !ok {
  551. return
  552. }
  553. id := arg["id"].(string)
  554. idx := arg["index"]
  555. index := 0
  556. if nil != idx {
  557. index = int(idx.(float64))
  558. }
  559. k := arg["k"]
  560. var keyword string
  561. if nil != k {
  562. keyword = k.(string)
  563. }
  564. m := arg["mode"] // 0: 仅当前 ID,1:向上 2:向下,3:上下都加载,4:加载末尾
  565. mode := 0
  566. if nil != m {
  567. mode = int(m.(float64))
  568. }
  569. s := arg["size"]
  570. size := 102400 // 默认最大加载块数
  571. if nil != s {
  572. size = int(s.(float64))
  573. }
  574. startID := ""
  575. endID := ""
  576. startIDArg := arg["startID"]
  577. endIDArg := arg["endID"]
  578. if nil != startIDArg && nil != endIDArg {
  579. startID = startIDArg.(string)
  580. endID = endIDArg.(string)
  581. size = 36
  582. }
  583. isBacklinkArg := arg["isBacklink"]
  584. isBacklink := false
  585. if nil != isBacklinkArg {
  586. isBacklink = isBacklinkArg.(bool)
  587. }
  588. blockCount, childBlockCount, content, parentID, parent2ID, rootID, typ, eof, boxID, docPath, isBacklinkExpand, err := model.GetDoc(startID, endID, id, index, keyword, mode, size, isBacklink)
  589. if errors.Is(err, filelock.ErrUnableAccessFile) {
  590. ret.Code = 2
  591. ret.Data = id
  592. return
  593. }
  594. if model.ErrBlockNotFound == err {
  595. ret.Code = 3
  596. return
  597. }
  598. if nil != err {
  599. ret.Code = 1
  600. ret.Msg = err.Error()
  601. return
  602. }
  603. // 判断是否正在同步中 https://github.com/siyuan-note/siyuan/issues/6290
  604. isSyncing := model.IsSyncingFile(rootID)
  605. ret.Data = map[string]interface{}{
  606. "id": id,
  607. "mode": mode,
  608. "parentID": parentID,
  609. "parent2ID": parent2ID,
  610. "rootID": rootID,
  611. "type": typ,
  612. "content": content,
  613. "blockCount": blockCount,
  614. "childBlockCount": childBlockCount,
  615. "eof": eof,
  616. "box": boxID,
  617. "path": docPath,
  618. "isSyncing": isSyncing,
  619. "isBacklinkExpand": isBacklinkExpand,
  620. }
  621. }
  622. func pushCreate(box *model.Box, p, treeID string, arg map[string]interface{}) {
  623. evt := util.NewCmdResult("create", 0, util.PushModeBroadcast)
  624. name := path.Base(p)
  625. files, _, _ := model.ListDocTree(box.ID, path.Dir(p), model.Conf.FileTree.Sort)
  626. evt.Data = map[string]interface{}{
  627. "box": box,
  628. "path": p,
  629. "files": files,
  630. "name": name,
  631. "id": treeID,
  632. }
  633. evt.Callback = arg["callback"]
  634. util.PushEvent(evt)
  635. }