MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / file_dstpath_check

Method file_dstpath_check

mod/project/node/executorMod.py:794–834  ·  view source on GitHub ↗
(get)

Source from the content-addressed store, hash-verified

792
793 @staticmethod
794 def file_dstpath_check(get):
795 path = get.get("path/s", "")
796 node_ids = list_args(get, "node_ids")
797 if not path or not node_ids:
798 return json_response(status=False, msg="参数错误")
799
800 if path == "/":
801 return json_response(status=False, msg="不能上传到根目录")
802
803 nodes_db = ServerNodeDB()
804 ret = []
805
806 def check_node(n_data:dict, t_srv: Union[ServerNode, LPanelNode, SSHApi]):
807 res = {"id": n_data["id"], "err": "", "remarks": n_data["remarks"]}
808 err = t_srv.upload_dir_check(path)
809 if err:
810 res["err"] = err
811 ret.append(res)
812
813 th_list = []
814 for i in node_ids:
815 n = nodes_db.get_node_by_id(i)
816 if not n:
817 ret.append({"id": i, "err": "节点不存在"})
818 n["ssh_conf"] = json.loads(n["ssh_conf"])
819 if n["app_key"] or n["api_key"]:
820 srv = ServerNode.new_by_data(n)
821 elif n["ssh_conf"]:
822 srv = SSHApi(**n["ssh_conf"])
823 else:
824 ret.append({"id": i, "err": "节点配置错误"})
825 continue
826
827 th = threading.Thread(target=check_node, args=(n, srv))
828 th.start()
829 th_list.append(th)
830
831 for th in th_list:
832 th.join()
833
834 return json_response(status=True, data=ret)
835
836 @staticmethod
837 def create_flow_template(get):

Callers

nothing calls this directly

Calls 11

get_node_by_idMethod · 0.95
list_argsFunction · 0.90
json_responseFunction · 0.90
ServerNodeDBClass · 0.90
SSHApiClass · 0.90
new_by_dataMethod · 0.80
getMethod · 0.45
appendMethod · 0.45
loadsMethod · 0.45
startMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected