filecat 5.15.5 → 5.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (316) hide show
  1. package/build/dist/181.11199e601b22f4add759.js +2 -0
  2. package/build/dist/{960.57837b4ef9e3838cf339.js → 301.0aa113cb4316e9e74a51.js} +2 -2
  3. package/build/dist/{325.fe78da5ba19c2104cc9e.js → 325.5f041ae7990615da279c.js} +2 -2
  4. package/build/dist/{523.560ce4ba9d2c7877058d.js → 523.cd76e6fafa6440cc1693.js} +2 -2
  5. package/build/dist/{757.964f68a8419e427d298f.js → 757.a6c2cab5ed6ce5776467.js} +1 -1
  6. package/build/dist/{793.da73c469f1ba286afc1b.js → 793.5ac9e1d8bc64790682d0.js} +2 -2
  7. package/build/dist/{827.b10a4f524c371d404cff.js → 827.e64e0af3c11c5bcd68c0.js} +2 -2
  8. package/build/dist/91.56af0d7eacb487e115b2.js +1 -0
  9. package/build/dist/{943.911e95ed97052f17913b.js → 943.7e28d7ce1a69f0d15eb2.js} +2 -2
  10. package/build/dist/995.ec4607dd8bb71cfb6a9d.js +2 -0
  11. package/build/dist/index.html +1 -1
  12. package/build/dist/main.7d110d8fdcc3c74c6c82.js +2 -0
  13. package/build/server/common/Env.js +188 -0
  14. package/build/server/common/Env.js.map +1 -0
  15. package/build/server/common/FileMenuType.js +45 -0
  16. package/build/server/common/FileMenuType.js.map +1 -0
  17. package/build/server/common/ListUtil.js +174 -0
  18. package/build/server/common/ListUtil.js.map +1 -0
  19. package/build/server/common/Result.pojo.js +14 -0
  20. package/build/server/common/Result.pojo.js.map +1 -0
  21. package/build/server/common/RouterConfig.js +16 -0
  22. package/build/server/common/RouterConfig.js.map +1 -0
  23. package/build/server/common/StringUtil.js +153 -0
  24. package/build/server/common/StringUtil.js.map +1 -0
  25. package/build/server/common/ValueUtil.js +49 -0
  26. package/build/server/common/ValueUtil.js.map +1 -0
  27. package/build/server/common/common.util.js +10 -0
  28. package/build/server/common/common.util.js.map +1 -0
  29. package/build/server/common/file.pojo.js +56 -0
  30. package/build/server/common/file.pojo.js.map +1 -0
  31. package/build/server/common/findPort.js +34 -0
  32. package/build/server/common/findPort.js.map +1 -0
  33. package/build/server/common/frame/WsData.js +168 -0
  34. package/build/server/common/frame/WsData.js.map +1 -0
  35. package/build/server/common/frame/router.js +25 -0
  36. package/build/server/common/frame/router.js.map +1 -0
  37. package/build/server/common/frame/ws.client.js +295 -0
  38. package/build/server/common/frame/ws.client.js.map +1 -0
  39. package/build/server/common/frame/ws.server.js +226 -0
  40. package/build/server/common/frame/ws.server.js.map +1 -0
  41. package/build/server/common/http.js +47 -0
  42. package/build/server/common/http.js.map +1 -0
  43. package/build/server/common/install.js +139 -0
  44. package/build/server/common/install.js.map +1 -0
  45. package/build/server/common/path_util.js +86 -0
  46. package/build/server/common/path_util.js.map +1 -0
  47. package/build/server/common/proto/proto.generate.js +23 -0
  48. package/build/server/common/proto/proto.generate.js.map +1 -0
  49. package/build/server/common/proto/proto.js +172 -0
  50. package/build/server/common/proto/proto.js.map +1 -0
  51. package/build/server/common/req/common.pojo.js +17 -0
  52. package/build/server/common/req/common.pojo.js.map +1 -0
  53. package/build/server/common/req/customerRouter.pojo.js +9 -0
  54. package/build/server/common/req/customerRouter.pojo.js.map +1 -0
  55. package/build/server/common/req/data.pojo.js +3 -0
  56. package/build/server/common/req/data.pojo.js.map +1 -0
  57. package/build/server/common/req/ddns.pojo.js +39 -0
  58. package/build/server/common/req/ddns.pojo.js.map +1 -0
  59. package/build/server/common/req/file.req.js +46 -0
  60. package/build/server/common/req/file.req.js.map +1 -0
  61. package/build/server/common/req/http_controller_router.js +13 -0
  62. package/build/server/common/req/http_controller_router.js.map +1 -0
  63. package/build/server/common/req/net.pojo.js +49 -0
  64. package/build/server/common/req/net.pojo.js.map +1 -0
  65. package/build/server/common/req/setting.req.js +37 -0
  66. package/build/server/common/req/setting.req.js.map +1 -0
  67. package/build/server/common/req/ssh.pojo.js +13 -0
  68. package/build/server/common/req/ssh.pojo.js.map +1 -0
  69. package/build/server/common/req/sys.pojo.js +23 -0
  70. package/build/server/common/req/sys.pojo.js.map +1 -0
  71. package/build/server/common/req/user.req.js +91 -0
  72. package/build/server/common/req/user.req.js.map +1 -0
  73. package/build/server/common/word_detection_js.js +142 -0
  74. package/build/server/common/word_detection_js.js.map +1 -0
  75. package/build/server/main/domain/bin/bin.js +149 -0
  76. package/build/server/main/domain/bin/bin.js.map +1 -0
  77. package/build/server/main/domain/crypto/crypto.controller.js +63 -0
  78. package/build/server/main/domain/crypto/crypto.controller.js.map +1 -0
  79. package/build/server/main/domain/crypto/crypto.service.js +112 -0
  80. package/build/server/main/domain/crypto/crypto.service.js.map +1 -0
  81. package/build/server/main/domain/data/DataUtil.js +111 -0
  82. package/build/server/main/domain/data/DataUtil.js.map +1 -0
  83. package/build/server/main/domain/data/basedata/base_data_util.js +241 -0
  84. package/build/server/main/domain/data/basedata/base_data_util.js.map +1 -0
  85. package/build/server/main/domain/data/data_type.js +74 -0
  86. package/build/server/main/domain/data/data_type.js.map +1 -0
  87. package/build/server/main/domain/ddns/ddns.ali.server.js +88 -0
  88. package/build/server/main/domain/ddns/ddns.ali.server.js.map +1 -0
  89. package/build/server/main/domain/ddns/ddns.controller.js +103 -0
  90. package/build/server/main/domain/ddns/ddns.controller.js.map +1 -0
  91. package/build/server/main/domain/ddns/ddns.dnspod.service.js +121 -0
  92. package/build/server/main/domain/ddns/ddns.dnspod.service.js.map +1 -0
  93. package/build/server/main/domain/ddns/ddns.pre.js +120 -0
  94. package/build/server/main/domain/ddns/ddns.pre.js.map +1 -0
  95. package/build/server/main/domain/ddns/ddns.service.js +175 -0
  96. package/build/server/main/domain/ddns/ddns.service.js.map +1 -0
  97. package/build/server/main/domain/ddns/ddns.tengxun.service.js +57 -0
  98. package/build/server/main/domain/ddns/ddns.tengxun.service.js.map +1 -0
  99. package/build/server/main/domain/ddns/tx/abstract_client.js +270 -0
  100. package/build/server/main/domain/ddns/tx/abstract_client.js.map +1 -0
  101. package/build/server/main/domain/ddns/tx/dnspod_client.js +65 -0
  102. package/build/server/main/domain/ddns/tx/dnspod_client.js.map +1 -0
  103. package/build/server/main/domain/ddns/tx/dnspod_models.js +3 -0
  104. package/build/server/main/domain/ddns/tx/dnspod_models.js.map +1 -0
  105. package/build/server/main/domain/ddns/tx/exception/tencent_cloud_sdk_exception.js +38 -0
  106. package/build/server/main/domain/ddns/tx/exception/tencent_cloud_sdk_exception.js.map +1 -0
  107. package/build/server/main/domain/ddns/tx/http/fetch.js +3 -0
  108. package/build/server/main/domain/ddns/tx/http/fetch.js.map +1 -0
  109. package/build/server/main/domain/ddns/tx/http/http_connection.js +194 -0
  110. package/build/server/main/domain/ddns/tx/http/http_connection.js.map +1 -0
  111. package/build/server/main/domain/ddns/tx/interface.js +5 -0
  112. package/build/server/main/domain/ddns/tx/interface.js.map +1 -0
  113. package/build/server/main/domain/ddns/tx/sdk_version.js +5 -0
  114. package/build/server/main/domain/ddns/tx/sdk_version.js.map +1 -0
  115. package/build/server/main/domain/ddns/tx/sign.js +142 -0
  116. package/build/server/main/domain/ddns/tx/sign.js.map +1 -0
  117. package/build/server/main/domain/ddns/tx/sse_response_model.js +124 -0
  118. package/build/server/main/domain/ddns/tx/sse_response_model.js.map +1 -0
  119. package/build/server/main/domain/file/FileUtil.js +96 -0
  120. package/build/server/main/domain/file/FileUtil.js.map +1 -0
  121. package/build/server/main/domain/file/file.compress.js +131 -0
  122. package/build/server/main/domain/file/file.compress.js.map +1 -0
  123. package/build/server/main/domain/file/file.controller.js +483 -0
  124. package/build/server/main/domain/file/file.controller.js.map +1 -0
  125. package/build/server/main/domain/file/file.service.js +1123 -0
  126. package/build/server/main/domain/file/file.service.js.map +1 -0
  127. package/build/server/main/domain/file/search/file.search.js +83 -0
  128. package/build/server/main/domain/file/search/file.search.js.map +1 -0
  129. package/build/server/main/domain/file/search/file.search.worker.js +100 -0
  130. package/build/server/main/domain/file/search/file.search.worker.js.map +1 -0
  131. package/build/server/main/domain/file/search/file.type.js +3 -0
  132. package/build/server/main/domain/file/search/file.type.js.map +1 -0
  133. package/build/server/main/domain/file/workflow/workflow.process.js +104 -0
  134. package/build/server/main/domain/file/workflow/workflow.process.js.map +1 -0
  135. package/build/server/main/domain/file/workflow/workflow.service.js +687 -0
  136. package/build/server/main/domain/file/workflow/workflow.service.js.map +1 -0
  137. package/build/server/main/domain/file/workflow/workflow.util.js +121 -0
  138. package/build/server/main/domain/file/workflow/workflow.util.js.map +1 -0
  139. package/build/server/main/domain/navindex/navindex.controller.js +73 -0
  140. package/build/server/main/domain/navindex/navindex.controller.js.map +1 -0
  141. package/build/server/main/domain/net/net.controller.js +196 -0
  142. package/build/server/main/domain/net/net.controller.js.map +1 -0
  143. package/build/server/main/domain/net/net.datautil.js +8 -0
  144. package/build/server/main/domain/net/net.datautil.js.map +1 -0
  145. package/build/server/main/domain/net/net.service.js +415 -0
  146. package/build/server/main/domain/net/net.service.js.map +1 -0
  147. package/build/server/main/domain/net/util/NetClientUtil.js +246 -0
  148. package/build/server/main/domain/net/util/NetClientUtil.js.map +1 -0
  149. package/build/server/main/domain/net/util/NetServerUtil.js +128 -0
  150. package/build/server/main/domain/net/util/NetServerUtil.js.map +1 -0
  151. package/build/server/main/domain/net/util/NetUtil.js +129 -0
  152. package/build/server/main/domain/net/util/NetUtil.js.map +1 -0
  153. package/build/server/main/domain/net/util/tcp.util.js +137 -0
  154. package/build/server/main/domain/net/util/tcp.util.js.map +1 -0
  155. package/build/server/main/domain/net/util/udp.util.js +28 -0
  156. package/build/server/main/domain/net/util/udp.util.js.map +1 -0
  157. package/build/server/main/domain/net/virtual/tcp_proxy.js +106 -0
  158. package/build/server/main/domain/net/virtual/tcp_proxy.js.map +1 -0
  159. package/build/server/main/domain/net/virtual/virtual.client.service.js +445 -0
  160. package/build/server/main/domain/net/virtual/virtual.client.service.js.map +1 -0
  161. package/build/server/main/domain/net/virtual/virtual.controller.js +263 -0
  162. package/build/server/main/domain/net/virtual/virtual.controller.js.map +1 -0
  163. package/build/server/main/domain/net/virtual/virtual.server.service.js +91 -0
  164. package/build/server/main/domain/net/virtual/virtual.server.service.js.map +1 -0
  165. package/build/server/main/domain/pre/lifeRecordService.js +92 -0
  166. package/build/server/main/domain/pre/lifeRecordService.js.map +1 -0
  167. package/build/server/main/domain/rdp/lib/asn1/ber.js +66 -0
  168. package/build/server/main/domain/rdp/lib/asn1/ber.js.map +1 -0
  169. package/build/server/main/domain/rdp/lib/asn1/index.js +9 -0
  170. package/build/server/main/domain/rdp/lib/asn1/index.js.map +1 -0
  171. package/build/server/main/domain/rdp/lib/asn1/spec.js +56 -0
  172. package/build/server/main/domain/rdp/lib/asn1/spec.js.map +1 -0
  173. package/build/server/main/domain/rdp/lib/asn1/univ.js +315 -0
  174. package/build/server/main/domain/rdp/lib/asn1/univ.js.map +1 -0
  175. package/build/server/main/domain/rdp/lib/core/error.js +25 -0
  176. package/build/server/main/domain/rdp/lib/core/error.js.map +1 -0
  177. package/build/server/main/domain/rdp/lib/core/index.js +13 -0
  178. package/build/server/main/domain/rdp/lib/core/index.js.map +1 -0
  179. package/build/server/main/domain/rdp/lib/core/layer.js +135 -0
  180. package/build/server/main/domain/rdp/lib/core/layer.js.map +1 -0
  181. package/build/server/main/domain/rdp/lib/core/log.js +25 -0
  182. package/build/server/main/domain/rdp/lib/core/log.js.map +1 -0
  183. package/build/server/main/domain/rdp/lib/core/rle.js +22699 -0
  184. package/build/server/main/domain/rdp/lib/core/rle.js.map +1 -0
  185. package/build/server/main/domain/rdp/lib/core/type.js +245 -0
  186. package/build/server/main/domain/rdp/lib/core/type.js.map +1 -0
  187. package/build/server/main/domain/rdp/lib/index.js +6 -0
  188. package/build/server/main/domain/rdp/lib/index.js.map +1 -0
  189. package/build/server/main/domain/rdp/lib/protocol/cert.js +115 -0
  190. package/build/server/main/domain/rdp/lib/protocol/cert.js.map +1 -0
  191. package/build/server/main/domain/rdp/lib/protocol/index.js +11 -0
  192. package/build/server/main/domain/rdp/lib/protocol/index.js.map +1 -0
  193. package/build/server/main/domain/rdp/lib/protocol/nla.js +549 -0
  194. package/build/server/main/domain/rdp/lib/protocol/nla.js.map +1 -0
  195. package/build/server/main/domain/rdp/lib/protocol/pdu/caps.js +486 -0
  196. package/build/server/main/domain/rdp/lib/protocol/pdu/caps.js.map +1 -0
  197. package/build/server/main/domain/rdp/lib/protocol/pdu/cliprdr.js +167 -0
  198. package/build/server/main/domain/rdp/lib/protocol/pdu/cliprdr.js.map +1 -0
  199. package/build/server/main/domain/rdp/lib/protocol/pdu/data.js +876 -0
  200. package/build/server/main/domain/rdp/lib/protocol/pdu/data.js.map +1 -0
  201. package/build/server/main/domain/rdp/lib/protocol/pdu/global.js +260 -0
  202. package/build/server/main/domain/rdp/lib/protocol/pdu/global.js.map +1 -0
  203. package/build/server/main/domain/rdp/lib/protocol/pdu/index.js +13 -0
  204. package/build/server/main/domain/rdp/lib/protocol/pdu/index.js.map +1 -0
  205. package/build/server/main/domain/rdp/lib/protocol/pdu/lic.js +199 -0
  206. package/build/server/main/domain/rdp/lib/protocol/pdu/lic.js.map +1 -0
  207. package/build/server/main/domain/rdp/lib/protocol/pdu/sec.js +333 -0
  208. package/build/server/main/domain/rdp/lib/protocol/pdu/sec.js.map +1 -0
  209. package/build/server/main/domain/rdp/lib/protocol/rdp.js +255 -0
  210. package/build/server/main/domain/rdp/lib/protocol/rdp.js.map +1 -0
  211. package/build/server/main/domain/rdp/lib/protocol/t125/gcc.js +354 -0
  212. package/build/server/main/domain/rdp/lib/protocol/t125/gcc.js.map +1 -0
  213. package/build/server/main/domain/rdp/lib/protocol/t125/index.js +7 -0
  214. package/build/server/main/domain/rdp/lib/protocol/t125/index.js.map +1 -0
  215. package/build/server/main/domain/rdp/lib/protocol/t125/mcs.js +318 -0
  216. package/build/server/main/domain/rdp/lib/protocol/t125/mcs.js.map +1 -0
  217. package/build/server/main/domain/rdp/lib/protocol/t125/per.js +188 -0
  218. package/build/server/main/domain/rdp/lib/protocol/t125/per.js.map +1 -0
  219. package/build/server/main/domain/rdp/lib/protocol/tpkt.js +94 -0
  220. package/build/server/main/domain/rdp/lib/protocol/tpkt.js.map +1 -0
  221. package/build/server/main/domain/rdp/lib/protocol/x224.js +207 -0
  222. package/build/server/main/domain/rdp/lib/protocol/x224.js.map +1 -0
  223. package/build/server/main/domain/rdp/lib/security/index.js +7 -0
  224. package/build/server/main/domain/rdp/lib/security/index.js.map +1 -0
  225. package/build/server/main/domain/rdp/lib/security/jsbn.js +1372 -0
  226. package/build/server/main/domain/rdp/lib/security/jsbn.js.map +1 -0
  227. package/build/server/main/domain/rdp/lib/security/md4.js +401 -0
  228. package/build/server/main/domain/rdp/lib/security/md4.js.map +1 -0
  229. package/build/server/main/domain/rdp/lib/security/rc4.js +45 -0
  230. package/build/server/main/domain/rdp/lib/security/rc4.js.map +1 -0
  231. package/build/server/main/domain/rdp/lib/security/rsa.js +15 -0
  232. package/build/server/main/domain/rdp/lib/security/rsa.js.map +1 -0
  233. package/build/server/main/domain/rdp/lib/security/x509.js +106 -0
  234. package/build/server/main/domain/rdp/lib/security/x509.js.map +1 -0
  235. package/build/server/main/domain/rdp/rdp.controller.js +137 -0
  236. package/build/server/main/domain/rdp/rdp.controller.js.map +1 -0
  237. package/build/server/main/domain/rdp/rdp.service.js +137 -0
  238. package/build/server/main/domain/rdp/rdp.service.js.map +1 -0
  239. package/build/server/main/domain/setting/setting.controller.js +518 -0
  240. package/build/server/main/domain/setting/setting.controller.js.map +1 -0
  241. package/build/server/main/domain/setting/setting.prefile.js +74 -0
  242. package/build/server/main/domain/setting/setting.prefile.js.map +1 -0
  243. package/build/server/main/domain/setting/setting.service.js +550 -0
  244. package/build/server/main/domain/setting/setting.service.js.map +1 -0
  245. package/build/server/main/domain/shell/shell.controller.js +115 -0
  246. package/build/server/main/domain/shell/shell.controller.js.map +1 -0
  247. package/build/server/main/domain/shell/shell.service.js +443 -0
  248. package/build/server/main/domain/shell/shell.service.js.map +1 -0
  249. package/build/server/main/domain/ssh/ssh.controller.js +236 -0
  250. package/build/server/main/domain/ssh/ssh.controller.js.map +1 -0
  251. package/build/server/main/domain/ssh/ssh.service.js +271 -0
  252. package/build/server/main/domain/ssh/ssh.service.js.map +1 -0
  253. package/build/server/main/domain/ssh/ssh.ssh2.js +250 -0
  254. package/build/server/main/domain/ssh/ssh.ssh2.js.map +1 -0
  255. package/build/server/main/domain/sys/sys.controller.js +395 -0
  256. package/build/server/main/domain/sys/sys.controller.js.map +1 -0
  257. package/build/server/main/domain/sys/sys.docker.service.js +367 -0
  258. package/build/server/main/domain/sys/sys.docker.service.js.map +1 -0
  259. package/build/server/main/domain/sys/sys.process.service.js +239 -0
  260. package/build/server/main/domain/sys/sys.process.service.js.map +1 -0
  261. package/build/server/main/domain/sys/sys.service.js +101 -0
  262. package/build/server/main/domain/sys/sys.service.js.map +1 -0
  263. package/build/server/main/domain/sys/sys.sys.service.js +192 -0
  264. package/build/server/main/domain/sys/sys.sys.service.js.map +1 -0
  265. package/build/server/main/domain/sys/sys.systemd.service.js +306 -0
  266. package/build/server/main/domain/sys/sys.systemd.service.js.map +1 -0
  267. package/build/server/main/domain/sys/sys.utl.js +23 -0
  268. package/build/server/main/domain/sys/sys.utl.js.map +1 -0
  269. package/build/server/main/domain/user/user.controller.js +264 -0
  270. package/build/server/main/domain/user/user.controller.js.map +1 -0
  271. package/build/server/main/domain/user/user.hash.js +8 -0
  272. package/build/server/main/domain/user/user.hash.js.map +1 -0
  273. package/build/server/main/domain/user/user.service.js +573 -0
  274. package/build/server/main/domain/user/user.service.js.map +1 -0
  275. package/build/server/main/domain/video/video.controller.js +71 -0
  276. package/build/server/main/domain/video/video.controller.js.map +1 -0
  277. package/build/server/main/domain/video/video.service.js +45 -0
  278. package/build/server/main/domain/video/video.service.js.map +1 -0
  279. package/build/server/main/other/Result.js +25 -0
  280. package/build/server/main/other/Result.js.map +1 -0
  281. package/build/server/main/other/cache.js +50 -0
  282. package/build/server/main/other/cache.js.map +1 -0
  283. package/build/server/main/other/config.js +6 -0
  284. package/build/server/main/other/config.js.map +1 -0
  285. package/build/server/main/other/middleware/AuthMiddleware.js +72 -0
  286. package/build/server/main/other/middleware/AuthMiddleware.js.map +1 -0
  287. package/build/server/main/other/middleware/GlobalErrorHandler.js +23 -0
  288. package/build/server/main/other/middleware/GlobalErrorHandler.js.map +1 -0
  289. package/build/server/main/other/middleware/redirect.js +20 -0
  290. package/build/server/main/other/middleware/redirect.js.map +1 -0
  291. package/build/server/main/server.js +155 -0
  292. package/build/server/main/server.js.map +1 -0
  293. package/build/{watch.js → server/main/watch.js} +68 -86
  294. package/build/server/main/watch.js.map +1 -0
  295. package/build/server/tsconfig.tsbuildinfo +1 -0
  296. package/build/server/web/project/util/noty.js +60 -0
  297. package/build/server/web/project/util/noty.js.map +1 -0
  298. package/build/server/web/project/util/ws.js +7 -0
  299. package/build/server/web/project/util/ws.js.map +1 -0
  300. package/package.json +2 -1
  301. package/build/dist/181.ed11230f80088fa2a5b9.js +0 -2
  302. package/build/dist/91.21f368e687ef087ba623.js +0 -1
  303. package/build/dist/995.f5461272d4fd82df7130.js +0 -2
  304. package/build/dist/main.52dd483a8eaca68037ca.js +0 -2
  305. package/build/main.js +0 -2
  306. package/build/main.js.LICENSE.txt +0 -445
  307. package/build/unrar.wasm +0 -0
  308. /package/build/dist/{181.ed11230f80088fa2a5b9.js.LICENSE.txt → 181.11199e601b22f4add759.js.LICENSE.txt} +0 -0
  309. /package/build/dist/{960.57837b4ef9e3838cf339.js.LICENSE.txt → 301.0aa113cb4316e9e74a51.js.LICENSE.txt} +0 -0
  310. /package/build/dist/{325.fe78da5ba19c2104cc9e.js.LICENSE.txt → 325.5f041ae7990615da279c.js.LICENSE.txt} +0 -0
  311. /package/build/dist/{523.560ce4ba9d2c7877058d.js.LICENSE.txt → 523.cd76e6fafa6440cc1693.js.LICENSE.txt} +0 -0
  312. /package/build/dist/{793.da73c469f1ba286afc1b.js.LICENSE.txt → 793.5ac9e1d8bc64790682d0.js.LICENSE.txt} +0 -0
  313. /package/build/dist/{827.b10a4f524c371d404cff.js.LICENSE.txt → 827.e64e0af3c11c5bcd68c0.js.LICENSE.txt} +0 -0
  314. /package/build/dist/{943.911e95ed97052f17913b.js.LICENSE.txt → 943.7e28d7ce1a69f0d15eb2.js.LICENSE.txt} +0 -0
  315. /package/build/dist/{995.f5461272d4fd82df7130.js.LICENSE.txt → 995.ec4607dd8bb71cfb6a9d.js.LICENSE.txt} +0 -0
  316. /package/build/dist/{main.52dd483a8eaca68037ca.js.LICENSE.txt → main.7d110d8fdcc3c74c6c82.js.LICENSE.txt} +0 -0
@@ -0,0 +1,1123 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.FileServiceImpl = exports.FileService = void 0;
16
+ const file_pojo_1 = require("../../../common/file.pojo");
17
+ const fs_1 = __importDefault(require("fs"));
18
+ const fs_extra_1 = __importDefault(require("fs-extra"));
19
+ const path_1 = __importDefault(require("path"));
20
+ const Result_1 = require("../../other/Result");
21
+ const rimraf_1 = require("rimraf");
22
+ const ValueUtil_1 = require("../../../common/ValueUtil");
23
+ const setting_service_1 = require("../setting/setting.service");
24
+ const WsData_1 = require("../../../common/frame/WsData");
25
+ const Result_pojo_1 = require("../../../common/Result.pojo");
26
+ const file_compress_1 = require("./file.compress");
27
+ const bin_1 = require("../bin/bin");
28
+ const FileMenuType_1 = require("../../../common/FileMenuType");
29
+ const StringUtil_1 = require("../../../common/StringUtil");
30
+ const systeminformation_1 = __importDefault(require("systeminformation"));
31
+ const multer_1 = __importDefault(require("multer"));
32
+ const user_service_1 = require("../user/user.service");
33
+ const user_req_1 = require("../../../common/req/user.req");
34
+ const FileUtil_1 = require("./FileUtil");
35
+ const node_process_watcher_1 = require("node-process-watcher");
36
+ const archiver = require('archiver');
37
+ const mime = require('mime-types');
38
+ const chokidar = require('chokidar');
39
+ const iconv = require('iconv-lite');
40
+ class FileService extends file_compress_1.FileCompress {
41
+ constructor() {
42
+ super(...arguments);
43
+ this.fileUploadOptions = {
44
+ storage: multer_1.default.diskStorage({
45
+ destination: (req, file, cb) => {
46
+ cb(null, req.fileDir);
47
+ },
48
+ filename: (req, file, cb) => {
49
+ cb(null, req.fileName);
50
+ }
51
+ })
52
+ };
53
+ this.upload = (0, multer_1.default)({
54
+ storage: this.fileUploadOptions.storage,
55
+ }).single('file');
56
+ this.upload_num_set = {};
57
+ this.file_upload_count_map = new Map();
58
+ this.file_change_watcher_map = new Map();
59
+ }
60
+ utf8ToEncoding(utf8Str, targetEncoding, outputFormat = 'buffer') {
61
+ const buffer = iconv.encode(utf8Str, targetEncoding);
62
+ switch (outputFormat.toLowerCase()) {
63
+ case 'buffer':
64
+ return buffer;
65
+ case 'hex':
66
+ return buffer.toString('hex');
67
+ case 'base64':
68
+ return buffer.toString('base64');
69
+ case 'string':
70
+ if (['latin1', 'iso-8859-1'].includes(targetEncoding.toLowerCase())) {
71
+ return buffer.toString('binary');
72
+ }
73
+ else {
74
+ throw new Error(`outputFormat 'string' 仅支持 'latin1' 或 'iso-8859-1' 编码`);
75
+ }
76
+ default:
77
+ throw new Error(`不支持的 outputFormat: ${outputFormat},可选 'buffer' | 'hex' | 'base64' | 'string'`);
78
+ }
79
+ }
80
+ getFile(param_path, token, is_sys_path) {
81
+ return __awaiter(this, void 0, void 0, function* () {
82
+ var _a, _b, _c;
83
+ const result = {
84
+ files: [],
85
+ folders: [],
86
+ relative_user_path: undefined
87
+ };
88
+ if (is_sys_path === 1 && decodeURIComponent(param_path) === "/etc/fstab") {
89
+ user_service_1.userService.check_user_auth(token, user_req_1.UserAuth.sys_disk_mount);
90
+ }
91
+ const root_path = setting_service_1.settingService.getFileRootPath(token);
92
+ const sysPath = is_sys_path === 1 ? `${decodeURIComponent(param_path)}` : path_1.default.join(root_path, param_path ? decodeURIComponent(param_path) : "");
93
+ user_service_1.userService.check_user_path(token, sysPath);
94
+ if (!(yield FileUtil_1.FileUtil.access(sysPath))) {
95
+ return (0, Result_1.Fail)("路径不存在", Result_pojo_1.RCode.Fail);
96
+ }
97
+ const stats = fs_1.default.statSync(sysPath);
98
+ if (stats.isFile()) {
99
+ const name = path_1.default.basename(sysPath);
100
+ const buffer = yield FileUtil_1.FileUtil.readFileSync(sysPath);
101
+ const pojo = (0, Result_1.Sucess)(buffer.toString(), Result_pojo_1.RCode.PreFile);
102
+ pojo.message = name;
103
+ return pojo;
104
+ }
105
+ else {
106
+ if (!stats.isDirectory()) {
107
+ return (0, Result_1.Fail)("不是文件", Result_pojo_1.RCode.Fail);
108
+ }
109
+ }
110
+ if (is_sys_path === 1) {
111
+ if (sysPath.startsWith(root_path)) {
112
+ result.relative_user_path = sysPath.substring(root_path.length);
113
+ }
114
+ return (0, Result_1.Sucess)(result);
115
+ }
116
+ const items = yield FileUtil_1.FileUtil.readdirSync(sysPath);
117
+ for (const item of items) {
118
+ const filePath = path_1.default.join(sysPath, item);
119
+ let stats = null;
120
+ try {
121
+ stats = yield FileUtil_1.FileUtil.statSync(filePath);
122
+ }
123
+ catch (e) {
124
+ console.log("读取错误", e);
125
+ }
126
+ const mtime = stats ? new Date(stats.mtime).getTime() : 0;
127
+ if (stats && stats.isFile()) {
128
+ const type = (0, FileMenuType_1.getFileFormat)(item);
129
+ (_a = result.files) === null || _a === void 0 ? void 0 : _a.push({
130
+ type: type,
131
+ name: item,
132
+ mtime: mtime,
133
+ size: stats.size,
134
+ isLink: stats === null || stats === void 0 ? void 0 : stats.isSymbolicLink(),
135
+ path: path_1.default.join(param_path, item)
136
+ });
137
+ }
138
+ else if (stats && stats.isDirectory()) {
139
+ (_b = result.folders) === null || _b === void 0 ? void 0 : _b.push({
140
+ type: file_pojo_1.FileTypeEnum.folder,
141
+ name: item,
142
+ mtime: mtime,
143
+ isLink: stats === null || stats === void 0 ? void 0 : stats.isSymbolicLink(),
144
+ path: param_path
145
+ });
146
+ }
147
+ else {
148
+ (_c = result.files) === null || _c === void 0 ? void 0 : _c.push({
149
+ type: file_pojo_1.FileTypeEnum.dev,
150
+ name: item,
151
+ mtime: mtime,
152
+ size: stats === null || stats === void 0 ? void 0 : stats.size,
153
+ path: path_1.default.join(param_path, item)
154
+ });
155
+ }
156
+ }
157
+ return (0, Result_1.Sucess)(result);
158
+ });
159
+ }
160
+ get_folder_info(fpath, token, wss) {
161
+ return __awaiter(this, void 0, void 0, function* () {
162
+ const sysPath = path_1.default.join(setting_service_1.settingService.getFileRootPath(token), decodeURIComponent(fpath));
163
+ user_service_1.userService.check_user_path(token, sysPath);
164
+ node_process_watcher_1.node_process_watcher.on_folder_size(sysPath, (file_num, total_size) => {
165
+ wss.send(WsData_1.CmdType.folder_size_info, [file_num, total_size]);
166
+ });
167
+ wss.setClose(() => {
168
+ node_process_watcher_1.node_process_watcher.stop_folder_size(sysPath);
169
+ });
170
+ });
171
+ }
172
+ stop_folder_info(fpath, token) {
173
+ return __awaiter(this, void 0, void 0, function* () {
174
+ const sysPath = path_1.default.join(setting_service_1.settingService.getFileRootPath(token), decodeURIComponent(fpath));
175
+ user_service_1.userService.check_user_path(token, sysPath);
176
+ node_process_watcher_1.node_process_watcher.stop_folder_size(sysPath);
177
+ });
178
+ }
179
+ getFileInfo(type, fpath, token, wss) {
180
+ return __awaiter(this, void 0, void 0, function* () {
181
+ let info = {};
182
+ const sysPath = path_1.default.join(setting_service_1.settingService.getFileRootPath(token), decodeURIComponent(fpath));
183
+ user_service_1.userService.check_user_path(token, sysPath);
184
+ switch (type) {
185
+ case file_pojo_1.FileTypeEnum.folder:
186
+ if (wss) {
187
+ this.getDiskSizeForPath(sysPath).then(data => {
188
+ const result = new WsData_1.WsData(WsData_1.CmdType.file_info);
189
+ result.context = data;
190
+ wss.sendData(result.encode());
191
+ }).catch(error => {
192
+ console.log(error);
193
+ });
194
+ }
195
+ else {
196
+ info = yield this.getDiskSizeForPath(sysPath);
197
+ }
198
+ break;
199
+ case file_pojo_1.FileTypeEnum.upload_folder:
200
+ {
201
+ const list = setting_service_1.settingService.get_dir_upload_max_num();
202
+ for (const it of list) {
203
+ if (user_service_1.userService.isSubPath(it.path, sysPath)) {
204
+ info.dir_upload_max_num_value = it;
205
+ }
206
+ }
207
+ }
208
+ break;
209
+ default:
210
+ break;
211
+ }
212
+ info.now_absolute_path = sysPath;
213
+ return info;
214
+ });
215
+ }
216
+ uploadFile(filePath, req, res, token) {
217
+ return __awaiter(this, void 0, void 0, function* () {
218
+ const sysPath = path_1.default.join(setting_service_1.settingService.getFileRootPath(token), filePath ? decodeURIComponent(filePath) : "");
219
+ user_service_1.userService.check_user_path(token, sysPath);
220
+ user_service_1.userService.check_user_only_path(token, sysPath);
221
+ if ((req.query.dir === "1")) {
222
+ if (!(yield FileUtil_1.FileUtil.access(sysPath)))
223
+ yield FileUtil_1.FileUtil.mkdirSync(sysPath, { recursive: true });
224
+ return;
225
+ }
226
+ let upload_max_key;
227
+ let max_num;
228
+ for (const it of setting_service_1.settingService.get_dir_upload_max_num()) {
229
+ if (user_service_1.userService.isSubPath(it.path, sysPath) && it.sys_upload_num !== undefined) {
230
+ upload_max_key = it.path;
231
+ max_num = it.sys_upload_num;
232
+ }
233
+ }
234
+ if (upload_max_key) {
235
+ let v = this.upload_num_set[upload_max_key];
236
+ if (v === undefined) {
237
+ v = 1;
238
+ }
239
+ else {
240
+ v++;
241
+ }
242
+ if (v > max_num)
243
+ throw " upload file num max ";
244
+ this.upload_num_set[upload_max_key] = v;
245
+ }
246
+ req['fileDir'] = path_1.default.dirname(sysPath);
247
+ req['fileName'] = path_1.default.basename(sysPath);
248
+ req.on('close', () => {
249
+ if (upload_max_key) {
250
+ if (this.upload_num_set[upload_max_key]) {
251
+ this.upload_num_set[upload_max_key]--;
252
+ }
253
+ }
254
+ });
255
+ return new Promise((resolve) => {
256
+ try {
257
+ this.upload(req, res, (err) => {
258
+ if (err) {
259
+ console.log(err);
260
+ }
261
+ if (upload_max_key) {
262
+ if (this.upload_num_set[upload_max_key]) {
263
+ this.upload_num_set[upload_max_key]--;
264
+ }
265
+ }
266
+ resolve(1);
267
+ });
268
+ }
269
+ catch (e) {
270
+ if (upload_max_key) {
271
+ if (this.upload_num_set[upload_max_key]) {
272
+ this.upload_num_set[upload_max_key]--;
273
+ }
274
+ }
275
+ resolve(1);
276
+ }
277
+ });
278
+ });
279
+ }
280
+ file_upload_pre(data) {
281
+ return __awaiter(this, void 0, void 0, function* () {
282
+ const param = data.context;
283
+ const token = data.wss.token;
284
+ const sysPath = path_1.default.join(setting_service_1.settingService.getFileRootPath(token), param.file_path ? decodeURIComponent(param.file_path) : "");
285
+ user_service_1.userService.check_user_path(token, sysPath);
286
+ user_service_1.userService.check_user_only_path(token, sysPath);
287
+ if (param.is_dir) {
288
+ if (!(yield FileUtil_1.FileUtil.access(sysPath)))
289
+ yield FileUtil_1.FileUtil.mkdirSync(sysPath, { recursive: true });
290
+ return;
291
+ }
292
+ let max_num;
293
+ let upload_max_key;
294
+ for (const it of setting_service_1.settingService.get_dir_upload_max_num()) {
295
+ if (user_service_1.userService.isSubPath(it.path, sysPath) && it.sys_upload_num !== undefined) {
296
+ upload_max_key = it.path;
297
+ max_num = it.sys_upload_num;
298
+ }
299
+ }
300
+ if (upload_max_key) {
301
+ let v = this.upload_num_set[upload_max_key];
302
+ if (v === undefined) {
303
+ v = 1;
304
+ }
305
+ else {
306
+ v++;
307
+ }
308
+ if (v > max_num)
309
+ throw " upload file num max ";
310
+ this.upload_num_set[upload_max_key] = v;
311
+ }
312
+ data.wss.setClose(() => {
313
+ if (upload_max_key) {
314
+ if (this.upload_num_set[upload_max_key]) {
315
+ this.upload_num_set[upload_max_key]--;
316
+ }
317
+ }
318
+ });
319
+ let value = this.file_upload_count_map.get(sysPath);
320
+ if (value) {
321
+ value.buffer_list = new Array(param.parallel_done_num).fill(undefined);
322
+ value.parallel_done_num = 0;
323
+ if (param.lastModified !== value.lastModified) {
324
+ if (yield FileUtil_1.FileUtil.access(sysPath)) {
325
+ yield FileUtil_1.FileUtil.unlinkSync(sysPath);
326
+ }
327
+ }
328
+ else if (yield FileUtil_1.FileUtil.access(sysPath)) {
329
+ return { upload_data_size: value.upload_data_size };
330
+ }
331
+ }
332
+ this.lifeStart(sysPath, upload_max_key, (key) => __awaiter(this, void 0, void 0, function* () {
333
+ this.file_upload_count_map.delete(upload_max_key);
334
+ value.writeStream.end();
335
+ value.buffer_list = null;
336
+ this.file_upload_count_map.delete(sysPath);
337
+ }));
338
+ if (yield FileUtil_1.FileUtil.access(sysPath)) {
339
+ yield FileUtil_1.FileUtil.truncateSync(sysPath);
340
+ }
341
+ param.file_full_path = sysPath;
342
+ value = {
343
+ upload_data_size: 0,
344
+ wss: data.wss,
345
+ lastModified: param.lastModified,
346
+ buffer_list: new Array(param.parallel_done_num).fill(undefined),
347
+ sys_file_max_num: max_num,
348
+ sys_file_upload_max_key: upload_max_key,
349
+ parallel_done_num: 0,
350
+ writeStream: fs_1.default.createWriteStream(sysPath)
351
+ };
352
+ this.file_upload_count_map.set(sysPath, value);
353
+ return { upload_data_size: value.upload_data_size };
354
+ });
355
+ }
356
+ file_upload(data) {
357
+ return __awaiter(this, void 0, void 0, function* () {
358
+ const param = data.context;
359
+ const token = data.wss.token;
360
+ const sysPath = path_1.default.join(setting_service_1.settingService.getFileRootPath(token), param.file_path ? decodeURIComponent(param.file_path) : "");
361
+ user_service_1.userService.check_user_path(token, sysPath);
362
+ user_service_1.userService.check_user_only_path(token, sysPath);
363
+ this.lifeHeart(sysPath);
364
+ const num_value = this.file_upload_count_map.get(sysPath);
365
+ try {
366
+ num_value.buffer_list[param.part_count] = data.bin_context;
367
+ delete data.bin_context;
368
+ num_value.parallel_done_num++;
369
+ if (num_value.parallel_done_num !== param.parallel_done_num) {
370
+ return;
371
+ }
372
+ num_value.parallel_done_num = 0;
373
+ for (const add_chunk of num_value.buffer_list) {
374
+ num_value.writeStream.write(add_chunk);
375
+ num_value.upload_data_size += add_chunk.length;
376
+ }
377
+ num_value.buffer_list.length = 0;
378
+ num_value.buffer_list = new Array(param.parallel_done_num).fill(undefined);
379
+ if (param.chunk_index === param.total_chunk_index - 1) {
380
+ if (num_value.sys_file_upload_max_key) {
381
+ if (this.upload_num_set[num_value.sys_file_upload_max_key]) {
382
+ this.upload_num_set[num_value.sys_file_upload_max_key]--;
383
+ }
384
+ }
385
+ this.file_upload_count_map.delete(sysPath);
386
+ num_value.writeStream.end();
387
+ }
388
+ }
389
+ catch (e) {
390
+ console.log(e);
391
+ if (num_value.sys_file_upload_max_key) {
392
+ if (this.upload_num_set[num_value.sys_file_upload_max_key]) {
393
+ this.upload_num_set[num_value.sys_file_upload_max_key]--;
394
+ }
395
+ }
396
+ num_value.writeStream.end();
397
+ this.file_upload_count_map.delete(sysPath);
398
+ }
399
+ });
400
+ }
401
+ deletes(token, filePath) {
402
+ return __awaiter(this, void 0, void 0, function* () {
403
+ if (!filePath) {
404
+ return (0, Result_1.Sucess)("1");
405
+ }
406
+ let sysPath = path_1.default.join(setting_service_1.settingService.getFileRootPath(token), decodeURIComponent(filePath));
407
+ user_service_1.userService.check_user_path(token, sysPath);
408
+ if (user_service_1.userService.protectionCheck(sysPath, token) || setting_service_1.settingService.protectionCheck(sysPath)) {
409
+ return (0, Result_1.Fail)("1", Result_pojo_1.RCode.PROTECT_FILE);
410
+ }
411
+ if (setting_service_1.settingService.get_recycle_bin_status()) {
412
+ sysPath = (0, StringUtil_1.removeTrailingPath)(sysPath);
413
+ const cyc_map_list = setting_service_1.settingService.get_recycle_dir_map_list();
414
+ for (const it of cyc_map_list) {
415
+ let cyc_p;
416
+ let check_cyc_p = "";
417
+ if (it.length > 1 && !!it[1]) {
418
+ cyc_p = (0, StringUtil_1.removeTrailingPath)(it[1]);
419
+ check_cyc_p = it[0];
420
+ }
421
+ else {
422
+ cyc_p = (0, StringUtil_1.removeTrailingPath)(it[0]);
423
+ }
424
+ if (cyc_p === sysPath) {
425
+ throw "cyc dir not to del";
426
+ }
427
+ if (check_cyc_p !== "" && !user_service_1.userService.isSubPath(check_cyc_p, sysPath)) {
428
+ continue;
429
+ }
430
+ if (user_service_1.userService.isSubPath(cyc_p, sysPath)) {
431
+ continue;
432
+ }
433
+ const ext_name = path_1.default.extname(sysPath);
434
+ const fileName = path_1.default.basename(filePath, ext_name);
435
+ let p = path_1.default.join(cyc_p, `${fileName}${ext_name}`);
436
+ if (yield FileUtil_1.FileUtil.access(p)) {
437
+ p = yield FileUtil_1.FileUtil.getUniqueFileName(p);
438
+ }
439
+ yield this.cut_exec(sysPath, p);
440
+ return (0, Result_1.Sucess)("1");
441
+ }
442
+ }
443
+ const stats = yield FileUtil_1.FileUtil.statSync(sysPath);
444
+ if (stats.isFile()) {
445
+ yield FileUtil_1.FileUtil.unlinkSync(sysPath);
446
+ }
447
+ else {
448
+ yield (0, rimraf_1.rimraf)(sysPath);
449
+ }
450
+ return (0, Result_1.Sucess)("1");
451
+ });
452
+ }
453
+ save(token, context, filePath, is_sys_path) {
454
+ return __awaiter(this, void 0, void 0, function* () {
455
+ if (context === null || context === undefined) {
456
+ return;
457
+ }
458
+ const sysPath = is_sys_path === 1 ? `/${filePath}` : path_1.default.join(setting_service_1.settingService.getFileRootPath(token), filePath ? decodeURIComponent(filePath) : "");
459
+ user_service_1.userService.check_user_path(token, sysPath);
460
+ user_service_1.userService.check_user_only_path(token, sysPath);
461
+ yield FileUtil_1.FileUtil.writeFileSync(sysPath, context);
462
+ });
463
+ }
464
+ common_base64_save(token, filepath, base64_context, type) {
465
+ return __awaiter(this, void 0, void 0, function* () {
466
+ const sysPath = path_1.default.join(setting_service_1.settingService.getFileRootPath(token), filepath);
467
+ user_service_1.userService.check_user_path(token, sysPath);
468
+ user_service_1.userService.check_user_only_path(token, sysPath);
469
+ const binaryData = Buffer.from(base64_context, 'base64');
470
+ if (type === file_pojo_1.base64UploadType.all || type === file_pojo_1.base64UploadType.start) {
471
+ yield FileUtil_1.FileUtil.writeFileSync(sysPath, binaryData);
472
+ }
473
+ else if (type === file_pojo_1.base64UploadType.part) {
474
+ yield FileUtil_1.FileUtil.appendFileSync(sysPath, binaryData);
475
+ }
476
+ });
477
+ }
478
+ cut(token, data) {
479
+ return __awaiter(this, void 0, void 0, function* () {
480
+ if (!data) {
481
+ return;
482
+ }
483
+ const root_path = setting_service_1.settingService.getFileRootPath(token);
484
+ const sysPath = path_1.default.join(root_path);
485
+ const toSysPath = path_1.default.join(root_path, data.to ? decodeURIComponent(data.to) : "");
486
+ user_service_1.userService.check_user_path(token, sysPath);
487
+ user_service_1.userService.check_user_path(token, toSysPath);
488
+ for (const file of data.files) {
489
+ yield this.cut_exec(decodeURIComponent(path_1.default.join(sysPath, file)), decodeURIComponent(path_1.default.join(toSysPath, path_1.default.basename(file))));
490
+ }
491
+ });
492
+ }
493
+ cut_exec(source_path, to_file) {
494
+ return __awaiter(this, void 0, void 0, function* () {
495
+ yield FileUtil_1.FileUtil.renameSync(source_path, to_file);
496
+ yield (0, rimraf_1.rimraf)(source_path);
497
+ });
498
+ }
499
+ copy(token, data) {
500
+ return __awaiter(this, void 0, void 0, function* () {
501
+ if (!data) {
502
+ return;
503
+ }
504
+ const root_path = setting_service_1.settingService.getFileRootPath(token);
505
+ const sysPath = path_1.default.join(root_path);
506
+ const toSysPath = path_1.default.join(root_path, data.to ? decodeURIComponent(data.to) : "");
507
+ user_service_1.userService.check_user_path(token, sysPath);
508
+ user_service_1.userService.check_user_only_path(token, sysPath);
509
+ user_service_1.userService.check_user_path(token, toSysPath);
510
+ user_service_1.userService.check_user_only_path(token, toSysPath);
511
+ for (const file of data.files) {
512
+ const filePath = decodeURIComponent(path_1.default.join(sysPath, file));
513
+ yield fs_extra_1.default.copy(filePath, decodeURIComponent(path_1.default.join(toSysPath, path_1.default.basename(file))), { overwrite: true });
514
+ }
515
+ });
516
+ }
517
+ newFile(token, data) {
518
+ return __awaiter(this, void 0, void 0, function* () {
519
+ yield this.todoNew(token, 2, data);
520
+ });
521
+ }
522
+ newDir(token, data) {
523
+ return __awaiter(this, void 0, void 0, function* () {
524
+ yield this.todoNew(token, 1, data);
525
+ });
526
+ }
527
+ todoNew(token, type, data) {
528
+ return __awaiter(this, void 0, void 0, function* () {
529
+ var _a;
530
+ if (data === null || data === undefined) {
531
+ return;
532
+ }
533
+ const sysPath = path_1.default.join(setting_service_1.settingService.getFileRootPath(token), decodeURIComponent(data.name));
534
+ user_service_1.userService.check_user_path(token, sysPath);
535
+ user_service_1.userService.check_user_only_path(token, sysPath);
536
+ if (yield FileUtil_1.FileUtil.access(sysPath)) {
537
+ return;
538
+ }
539
+ if (type === 1) {
540
+ yield FileUtil_1.FileUtil.mkdirSync(sysPath, { recursive: true });
541
+ }
542
+ else {
543
+ yield FileUtil_1.FileUtil.writeFileSync(sysPath, (_a = data.context) !== null && _a !== void 0 ? _a : "");
544
+ }
545
+ });
546
+ }
547
+ rename(token, data) {
548
+ return __awaiter(this, void 0, void 0, function* () {
549
+ if (!data) {
550
+ return;
551
+ }
552
+ const root_path = setting_service_1.settingService.getFileRootPath(token);
553
+ const sysPath = path_1.default.join(root_path, decodeURIComponent(data.name));
554
+ user_service_1.userService.check_user_path(token, sysPath);
555
+ const sysPathNew = path_1.default.join(root_path, decodeURIComponent(data.newName));
556
+ yield fs_extra_1.default.rename(sysPath, sysPathNew);
557
+ });
558
+ }
559
+ download_one_file(file_name, file_size, file_path, res, param) {
560
+ const encodedFileName = encodeURIComponent(file_name).replace(/%20/g, '+');
561
+ let handle_type = "";
562
+ if ((param === null || param === void 0 ? void 0 : param.handle_type_) !== undefined) {
563
+ handle_type = param.handle_type_;
564
+ }
565
+ else {
566
+ handle_type = "attachment";
567
+ if (file_name.endsWith('.pdf')) {
568
+ handle_type = "inline";
569
+ }
570
+ }
571
+ res.set({
572
+ "Content-Type": mime.lookup(file_name) || "application/octet-stream",
573
+ "Content-Length": file_size,
574
+ "Content-Disposition": `${handle_type}; filename="${encodedFileName}"; filename*=UTF-8''${encodedFileName}`
575
+ });
576
+ if (param === null || param === void 0 ? void 0 : param.cache) {
577
+ res.setHeader('Cache-Control', 'public, max-age=86400 ');
578
+ }
579
+ else if (param === null || param === void 0 ? void 0 : param.cache_length) {
580
+ res.setHeader('Cache-Control', `public, max-age=${param.cache_length}`);
581
+ }
582
+ const readStream = fs_1.default.createReadStream(file_path);
583
+ readStream.pipe(res);
584
+ }
585
+ download(ctx) {
586
+ return __awaiter(this, void 0, void 0, function* () {
587
+ const file = ctx.query.file;
588
+ if (!file || !file.length) {
589
+ ctx.res.status(404).send('File not found');
590
+ return;
591
+ }
592
+ const token = ctx.query['token'];
593
+ const cache = ctx.query['cache'];
594
+ const show = ctx.query['show'];
595
+ if (!Array.isArray(file)) {
596
+ const sysPath = path_1.default.join(setting_service_1.settingService.getFileRootPath(token), decodeURIComponent(file));
597
+ const fileName = path_1.default.basename(sysPath);
598
+ const stats = yield FileUtil_1.FileUtil.statSync(sysPath);
599
+ const range = ctx.header("Range");
600
+ const fileSize = stats.size;
601
+ if (range) {
602
+ const encodedFileName = encodeURIComponent(fileName).replace(/%20/g, '+');
603
+ const [start, end] = range.replace(/bytes=/, "").split("-");
604
+ const startByte = parseInt(start, 10);
605
+ const endByte = end ? parseInt(end, 10) : fileSize - 1;
606
+ if (startByte >= fileSize) {
607
+ ctx.res.status(416).send("Requested range not satisfiable");
608
+ return;
609
+ }
610
+ const chunkSize = endByte - startByte + 1;
611
+ const readStream = fs_1.default.createReadStream(sysPath, { start: startByte, end: endByte });
612
+ ctx.res.status(206);
613
+ ctx.res.set({
614
+ "Content-Range": `bytes ${startByte}-${endByte}/${fileSize}`,
615
+ "Accept-Ranges": "bytes",
616
+ "Content-Length": chunkSize,
617
+ "Content-Type": mime.lookup(fileName) || "application/octet-stream",
618
+ "Content-Disposition": `attachment; filename="${encodedFileName}"; filename*=UTF-8''${encodedFileName}`
619
+ });
620
+ readStream.pipe(ctx.res);
621
+ return;
622
+ }
623
+ if (stats.isFile()) {
624
+ this.download_one_file(fileName, fileSize, sysPath, ctx.res, {
625
+ cache: cache === "1",
626
+ handle_type_: show === "1" ? "inline" : "attachment"
627
+ });
628
+ }
629
+ else {
630
+ ctx.res.attachment(path_1.default.basename(sysPath) + ".zip");
631
+ const archive = archiver('zip', { zlib: { level: 5 } });
632
+ archive.pipe(ctx.res);
633
+ archive.directory(sysPath, path_1.default.basename(sysPath));
634
+ archive.finalize();
635
+ }
636
+ }
637
+ else {
638
+ const files = file;
639
+ const archive = archiver('zip', {
640
+ zlib: { level: 5 }
641
+ });
642
+ ctx.res.attachment("output.zip");
643
+ ctx.res.set('Content-Type', 'application/octet-stream');
644
+ archive.pipe(ctx.res);
645
+ for (const file of files) {
646
+ const sysPath = path_1.default.join(setting_service_1.settingService.getFileRootPath(token), decodeURIComponent(file));
647
+ const stats = yield FileUtil_1.FileUtil.statSync(sysPath);
648
+ if (stats.isFile()) {
649
+ archive.file(sysPath, { name: path_1.default.basename(sysPath) });
650
+ }
651
+ else {
652
+ archive.directory(sysPath, path_1.default.basename(sysPath));
653
+ }
654
+ }
655
+ archive.finalize();
656
+ }
657
+ });
658
+ }
659
+ file_video_trans(data) {
660
+ const pojo = data.context;
661
+ user_service_1.userService.check_user_auth(pojo.token, user_req_1.UserAuth.filecat_file_context_update_upload_created_copy_decompression);
662
+ const wss = data.wss;
663
+ const root_path = setting_service_1.settingService.getFileRootPath(pojo.token);
664
+ const sysPath = path_1.default.join(root_path, decodeURIComponent(pojo.source_filename));
665
+ const sysPathNew = path_1.default.join(root_path, decodeURIComponent(pojo.to_filename));
666
+ (0, bin_1.getFfmpeg)()(sysPath)
667
+ .toFormat(pojo.to_format)
668
+ .on('start', function (commandLine) {
669
+ const result = new WsData_1.WsData(WsData_1.CmdType.file_video_trans_progress);
670
+ result.context = 0;
671
+ wss.sendData(result.encode());
672
+ })
673
+ .on('progress', function (progress) {
674
+ const result = new WsData_1.WsData(WsData_1.CmdType.file_video_trans_progress);
675
+ result.context = progress.percent.toFixed(0);
676
+ wss.sendData(result.encode());
677
+ })
678
+ .on('error', function (err, stdout, stderr) {
679
+ wss.ws.close();
680
+ })
681
+ .on('end', function () {
682
+ const result = new WsData_1.WsData(WsData_1.CmdType.file_video_trans_progress);
683
+ result.context = 100;
684
+ wss.sendData(result.encode());
685
+ })
686
+ .save(sysPathNew);
687
+ }
688
+ uncompress(data) {
689
+ return __awaiter(this, void 0, void 0, function* () {
690
+ var _a;
691
+ const pojo = data.context;
692
+ user_service_1.userService.check_user_auth(pojo.token, user_req_1.UserAuth.filecat_file_context_update_upload_created_copy_decompression);
693
+ const source_file = decodeURIComponent(pojo.source_file);
694
+ const tar_dir = decodeURIComponent((_a = pojo.tar_dir) !== null && _a !== void 0 ? _a : "");
695
+ const directoryPath = decodeURIComponent(path_1.default.dirname(source_file));
696
+ const root_path = setting_service_1.settingService.getFileRootPath(pojo.token);
697
+ const targetFolder = path_1.default.join(root_path, directoryPath, tar_dir);
698
+ user_service_1.userService.check_user_path(pojo.token, targetFolder);
699
+ user_service_1.userService.check_user_only_path(pojo.token, targetFolder);
700
+ const wss = data.wss;
701
+ if (tar_dir) {
702
+ yield FileUtil_1.FileUtil.mkdirSync(path_1.default.join(targetFolder), { recursive: true });
703
+ }
704
+ const sysSourcePath = path_1.default.join(root_path, source_file);
705
+ user_service_1.userService.check_user_path(pojo.token, sysSourcePath);
706
+ const outHanle = (value) => {
707
+ if (value === -1) {
708
+ wss.ws.close();
709
+ return;
710
+ }
711
+ const result = new WsData_1.WsData(WsData_1.CmdType.file_uncompress_progress);
712
+ result.context = value;
713
+ wss.sendData(result.encode());
714
+ };
715
+ if (pojo.format === file_pojo_1.FileCompressType.tar) {
716
+ this.unTar(sysSourcePath, targetFolder, outHanle);
717
+ }
718
+ else if (pojo.format === file_pojo_1.FileCompressType.zip) {
719
+ this.unZip(sysSourcePath, targetFolder, outHanle);
720
+ }
721
+ else if (pojo.format === file_pojo_1.FileCompressType.gzip) {
722
+ this.unTar(sysSourcePath, targetFolder, outHanle, true);
723
+ }
724
+ else if (pojo.format === file_pojo_1.FileCompressType.rar) {
725
+ try {
726
+ yield this.unRar(sysSourcePath, targetFolder, outHanle);
727
+ }
728
+ catch (e) {
729
+ wss.ws.close();
730
+ }
731
+ }
732
+ else {
733
+ wss.ws.close();
734
+ }
735
+ });
736
+ }
737
+ FileCompress(data) {
738
+ return __awaiter(this, void 0, void 0, function* () {
739
+ const pojo = data.context;
740
+ user_service_1.userService.check_user_auth(pojo.token, user_req_1.UserAuth.filecat_file_context_update_upload_created_copy_decompression);
741
+ const files = pojo.filePaths;
742
+ const root_path = setting_service_1.settingService.getFileRootPath(pojo.token);
743
+ const wss = data.wss;
744
+ const filePaths = [], directorys = [];
745
+ for (const file of files) {
746
+ const name = path_1.default.join(root_path, decodeURIComponent(file));
747
+ user_service_1.userService.check_user_path(pojo.token, name);
748
+ user_service_1.userService.check_user_only_path(pojo.token, name);
749
+ try {
750
+ const stats = yield FileUtil_1.FileUtil.statSync(name);
751
+ if (stats.isFile()) {
752
+ filePaths.push(name);
753
+ }
754
+ else {
755
+ directorys.push(name);
756
+ }
757
+ }
758
+ catch (e) {
759
+ }
760
+ }
761
+ let format;
762
+ switch (pojo.format) {
763
+ case file_pojo_1.FileCompressType.gzip:
764
+ format = file_pojo_1.FileCompressType.tar;
765
+ break;
766
+ default:
767
+ format = pojo.format;
768
+ }
769
+ const targerFilePath = path_1.default.join(root_path, decodeURIComponent(pojo.tar_filename));
770
+ this.compress(format, pojo.compress_level, targerFilePath, filePaths, directorys, (value) => {
771
+ if (value === -1) {
772
+ wss.ws.close();
773
+ return;
774
+ }
775
+ const result = new WsData_1.WsData(WsData_1.CmdType.file_compress_progress);
776
+ result.context = value;
777
+ wss.sendData(result.encode());
778
+ }, pojo.format === file_pojo_1.FileCompressType.gzip);
779
+ });
780
+ }
781
+ studio_get_item(param_path, token) {
782
+ return __awaiter(this, void 0, void 0, function* () {
783
+ const result = {
784
+ list: []
785
+ };
786
+ const sysPath = path_1.default.join(setting_service_1.settingService.getFileRootPath(token), param_path ? decodeURIComponent(param_path) : "");
787
+ user_service_1.userService.check_user_path(token, sysPath);
788
+ if (!(yield FileUtil_1.FileUtil.access(sysPath))) {
789
+ return (0, Result_1.Fail)("路径不存在", Result_pojo_1.RCode.Fail);
790
+ }
791
+ const stats = yield FileUtil_1.FileUtil.statSync(sysPath);
792
+ if (stats.isFile()) {
793
+ return (0, Result_1.Fail)("是文件", Result_pojo_1.RCode.Fail);
794
+ }
795
+ const items = yield FileUtil_1.FileUtil.readdirSync(sysPath);
796
+ for (const item of items) {
797
+ const filePath = path_1.default.join(sysPath, item);
798
+ let stats = null;
799
+ try {
800
+ stats = yield FileUtil_1.FileUtil.statSync(filePath);
801
+ }
802
+ catch (e) {
803
+ continue;
804
+ }
805
+ result.list.push({
806
+ type: stats.isFile() ? "file" : "folder",
807
+ name: item,
808
+ size: stats.size
809
+ });
810
+ }
811
+ return result;
812
+ });
813
+ }
814
+ getDiskSizeForPath(fpath) {
815
+ return __awaiter(this, void 0, void 0, function* () {
816
+ const pojo = {};
817
+ try {
818
+ const diskData = yield systeminformation_1.default.fsSize();
819
+ const dirPath = path_1.default.resolve(fpath);
820
+ let targetDisk;
821
+ diskData.forEach(disk => {
822
+ if (dirPath.startsWith(disk.mount)) {
823
+ if (!targetDisk) {
824
+ targetDisk = disk;
825
+ return;
826
+ }
827
+ else {
828
+ if (disk.mount.length > targetDisk.mount.length) {
829
+ targetDisk = disk;
830
+ }
831
+ }
832
+ }
833
+ });
834
+ if (targetDisk) {
835
+ pojo.path = dirPath;
836
+ pojo.name = path_1.default.basename(fpath);
837
+ pojo.total_size = (0, ValueUtil_1.formatFileSize)(targetDisk.size);
838
+ pojo.left_size = (0, ValueUtil_1.formatFileSize)(targetDisk.available);
839
+ pojo.fs_type = targetDisk.type;
840
+ }
841
+ }
842
+ catch (error) {
843
+ console.error('Error fetching disk information:', error);
844
+ return pojo;
845
+ }
846
+ return pojo;
847
+ });
848
+ }
849
+ isFirstByte(byte, encoding = "utf8") {
850
+ if (byte === undefined || byte < 0 || byte > 255)
851
+ throw 'Invalid byte';
852
+ switch (encoding.toLowerCase()) {
853
+ case 'utf8':
854
+ case 'utf-8':
855
+ return (byte & 0xE0) === 0xC0 || (byte & 0xF0) === 0xE0 || (byte & 0xF8) === 0xF0;
856
+ case 'ascii':
857
+ case 'latin1':
858
+ case 'iso-8859-1':
859
+ case 'windows-1252':
860
+ return true;
861
+ case 'gbk':
862
+ case 'gb2312':
863
+ return byte >= 0x81 && byte <= 0xFE;
864
+ case 'big5':
865
+ return byte >= 0x81 && byte <= 0xFE;
866
+ default:
867
+ throw 'Unsupported encoding for isFirstByte';
868
+ }
869
+ }
870
+ convertToUtf8(input, fromEncoding) {
871
+ if (fromEncoding === 'utf8' || fromEncoding === 'utf-8') {
872
+ return Buffer.isBuffer(input) ? input.toString('utf8') : input;
873
+ }
874
+ let buf;
875
+ if (typeof input === 'string') {
876
+ buf = iconv.encode(input, fromEncoding);
877
+ }
878
+ else if (Buffer.isBuffer(input)) {
879
+ buf = input;
880
+ }
881
+ else {
882
+ throw new Error('输入必须是 Buffer 或字符串');
883
+ }
884
+ const str = iconv.decode(buf, fromEncoding);
885
+ return str;
886
+ }
887
+ go_forward_log(pojo, file_path) {
888
+ return __awaiter(this, void 0, void 0, function* () {
889
+ let linesRead = 0;
890
+ let haveReadSize = 0;
891
+ const fd = yield FileUtil_1.FileUtil.open(file_path, "r");
892
+ let max_count = 100;
893
+ while (haveReadSize < pojo.once_max_size) {
894
+ if (max_count <= 0) {
895
+ break;
896
+ }
897
+ max_count--;
898
+ const buffer = Buffer.alloc(10240);
899
+ let { bytesRead } = yield fd.read(buffer, 0, buffer.length, pojo.position);
900
+ let done = false;
901
+ let last_h = -1;
902
+ for (let i = 0, ch_byte_i = bytesRead - 1; i < bytesRead; i++) {
903
+ if (buffer[i] === 10 || i === ch_byte_i) {
904
+ let index = i;
905
+ if (i === ch_byte_i && (buffer[i] & 0x80) !== 0) {
906
+ for (let j = i; j > last_h; j--) {
907
+ if (this.isFirstByte(buffer[j], pojo.encoding)) {
908
+ index = j - 1;
909
+ break;
910
+ }
911
+ }
912
+ }
913
+ linesRead++;
914
+ const now_str_start = last_h + 1;
915
+ const next_str_start = index + 1;
916
+ pojo.context_list.push(this.convertToUtf8(buffer.subarray(now_str_start, next_str_start), pojo.encoding));
917
+ pojo.context_start_position_list.push(pojo.position + now_str_start);
918
+ pojo.context_position_list.push(pojo.position + next_str_start);
919
+ if (linesRead >= pojo.line) {
920
+ done = true;
921
+ break;
922
+ }
923
+ last_h = index;
924
+ }
925
+ }
926
+ if (done || bytesRead === 0) {
927
+ break;
928
+ }
929
+ else {
930
+ haveReadSize += last_h;
931
+ pojo.position += last_h + 1;
932
+ }
933
+ }
934
+ yield fd.close();
935
+ return pojo;
936
+ });
937
+ }
938
+ find_back_enter_index(pojo_1, file_path_1) {
939
+ return __awaiter(this, arguments, void 0, function* (pojo, file_path, max_len = 10240) {
940
+ const fd = yield FileUtil_1.FileUtil.open(file_path, "r");
941
+ let buffer_len = max_len;
942
+ if (pojo.position < buffer_len) {
943
+ buffer_len = pojo.position;
944
+ }
945
+ let buffer = Buffer.alloc(buffer_len);
946
+ const position = pojo.position - buffer.length;
947
+ const { bytesRead } = yield fd.read(buffer, 0, buffer.length, position);
948
+ for (let i = bytesRead; i >= 0; i--) {
949
+ let index = i;
950
+ if (buffer[i] === 10 || i === 0) {
951
+ if ((buffer[i] & 0x80) !== 0) {
952
+ for (let j = 0; j < bytesRead; j++) {
953
+ if (this.isFirstByte(buffer[j], pojo.encoding)) {
954
+ index = j - 1;
955
+ break;
956
+ }
957
+ }
958
+ }
959
+ const now_str_start = index === 0 && pojo.position === 0 ? 0 : index + 1;
960
+ pojo.position = position + now_str_start;
961
+ yield fd.close();
962
+ return;
963
+ }
964
+ }
965
+ yield fd.close();
966
+ pojo.position = position;
967
+ });
968
+ }
969
+ go_back_log(pojo, file_path) {
970
+ return __awaiter(this, void 0, void 0, function* () {
971
+ let linesRead = 0;
972
+ let haveReadSize = 0;
973
+ const fd = yield FileUtil_1.FileUtil.open(file_path, "r");
974
+ let buffer_len = 10240;
975
+ let max_count = 100;
976
+ while (haveReadSize < pojo.once_max_size) {
977
+ if (max_count <= 0) {
978
+ break;
979
+ }
980
+ max_count--;
981
+ if (pojo.position < buffer_len) {
982
+ buffer_len = pojo.position;
983
+ }
984
+ let buffer = Buffer.alloc(buffer_len);
985
+ pojo.position = pojo.position - buffer.length;
986
+ const { bytesRead } = yield fd.read(buffer, 0, buffer.length, pojo.position);
987
+ let done = false;
988
+ let last_h = bytesRead;
989
+ for (let i = bytesRead; i >= 0; i--) {
990
+ let index = i;
991
+ if (buffer[i] === 10 || i === 0) {
992
+ if (i === 0 && pojo.position !== 0 && (buffer[i] & 0x80) !== 0) {
993
+ for (let j = 0; j < last_h; j++) {
994
+ if (this.isFirstByte(buffer[j], pojo.encoding)) {
995
+ index = j - 1;
996
+ break;
997
+ }
998
+ }
999
+ }
1000
+ linesRead++;
1001
+ const now_str_start = index === 0 && pojo.position === 0 ? 0 : index + 1;
1002
+ const next_str_start = last_h + 1;
1003
+ pojo.context_list.push(this.convertToUtf8(buffer.subarray(now_str_start, next_str_start), pojo.encoding));
1004
+ pojo.context_start_position_list.push(pojo.position + now_str_start);
1005
+ pojo.context_position_list.push(pojo.position + next_str_start);
1006
+ if (linesRead >= pojo.line) {
1007
+ done = true;
1008
+ break;
1009
+ }
1010
+ last_h = index;
1011
+ }
1012
+ }
1013
+ if (done || bytesRead === 0 || (last_h <= 0 && pojo.position === 0)) {
1014
+ break;
1015
+ }
1016
+ else {
1017
+ haveReadSize += (bytesRead - last_h);
1018
+ pojo.position -= last_h - 1;
1019
+ }
1020
+ }
1021
+ yield fd.close();
1022
+ return pojo;
1023
+ });
1024
+ }
1025
+ log_viewer(data) {
1026
+ return __awaiter(this, void 0, void 0, function* () {
1027
+ const pojo = data.context;
1028
+ pojo.context = "";
1029
+ pojo.context_list = [];
1030
+ pojo.context_position_list = [];
1031
+ pojo.context_start_position_list = [];
1032
+ const root_path = setting_service_1.settingService.getFileRootPath(pojo.token);
1033
+ const file_path = path_1.default.join(root_path, decodeURIComponent(pojo.path));
1034
+ user_service_1.userService.check_user_path(data.wss.token, file_path);
1035
+ const stats = yield FileUtil_1.FileUtil.statSync(file_path);
1036
+ const fileSize = stats.size;
1037
+ pojo.max_size = fileSize;
1038
+ if ((pojo.position <= 0 && pojo.back) || (!pojo.back && pojo.position >= fileSize)) {
1039
+ pojo.context = '';
1040
+ return pojo;
1041
+ }
1042
+ if (pojo.back)
1043
+ return this.go_back_log(pojo, file_path);
1044
+ if (pojo.find_back_enter_index)
1045
+ this.find_back_enter_index(pojo, file_path, 100);
1046
+ return this.go_forward_log(pojo, file_path);
1047
+ });
1048
+ }
1049
+ log_viewer_watch(data) {
1050
+ const pojo = data.context;
1051
+ if (this.file_change_watcher_map.has(pojo.token)) {
1052
+ return;
1053
+ }
1054
+ const wss = data.wss;
1055
+ pojo.context = "";
1056
+ pojo.context_list = [];
1057
+ pojo.context_position_list = [];
1058
+ pojo.context_start_position_list = [];
1059
+ const root_path = setting_service_1.settingService.getFileRootPath(pojo.token);
1060
+ const file_path = path_1.default.join(root_path, decodeURIComponent(pojo.path));
1061
+ user_service_1.userService.check_user_path(wss.token, file_path);
1062
+ let watcher = chokidar.watch(file_path, {
1063
+ persistent: true,
1064
+ usePolling: true,
1065
+ });
1066
+ this.file_change_watcher_map.set(pojo.token, watcher);
1067
+ wss.setClose(() => {
1068
+ watcher.close();
1069
+ this.file_change_watcher_map.delete(pojo.token);
1070
+ });
1071
+ let bytesRead = pojo.max_size;
1072
+ watcher.on('change', (changedFilePath) => {
1073
+ if (changedFilePath === file_path) {
1074
+ fs_1.default.stat(file_path, (err, stats) => {
1075
+ if (err) {
1076
+ console.error('Failed to get file stats:', err);
1077
+ watcher.close();
1078
+ this.file_change_watcher_map.delete(pojo.token);
1079
+ return;
1080
+ }
1081
+ if (stats.size > bytesRead) {
1082
+ const newStream = fs_1.default.createReadStream(file_path, { encoding: 'utf8', start: bytesRead });
1083
+ newStream.on('data', (chunk) => {
1084
+ const str = chunk.toString();
1085
+ let now_str_start = bytesRead;
1086
+ let next_str_start = bytesRead + chunk.length + 1;
1087
+ let index = 0;
1088
+ for (let i = 0; i < str.length; i++) {
1089
+ if (!/^\s$/.test(str[i])) {
1090
+ break;
1091
+ }
1092
+ else if (str[i] === '\n' && chunk.length - 1 > i) {
1093
+ index = i + 1;
1094
+ now_str_start = bytesRead + index;
1095
+ next_str_start + index;
1096
+ break;
1097
+ }
1098
+ }
1099
+ pojo.context_list.push(str.slice(index, chunk.length));
1100
+ pojo.context_start_position_list.push(now_str_start);
1101
+ pojo.context_position_list.push(next_str_start);
1102
+ pojo.max_size = bytesRead + chunk.length;
1103
+ const result = new WsData_1.WsData(WsData_1.CmdType.log_viewer_watch);
1104
+ result.context = pojo;
1105
+ wss.sendData(result.encode());
1106
+ bytesRead += Buffer.byteLength(chunk, 'utf8');
1107
+ pojo.context_list = [];
1108
+ pojo.context_position_list = [];
1109
+ pojo.context_start_position_list = [];
1110
+ });
1111
+ }
1112
+ });
1113
+ }
1114
+ });
1115
+ watcher.on('error', (error) => {
1116
+ watcher.close();
1117
+ this.file_change_watcher_map.delete(pojo.token);
1118
+ });
1119
+ }
1120
+ }
1121
+ exports.FileService = FileService;
1122
+ exports.FileServiceImpl = new FileService();
1123
+ //# sourceMappingURL=file.service.js.map