File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -191,21 +191,33 @@ clear_subscription_nodes() {
191191}
192192
193193# ######################################
194- # 刷新订阅目录
194+ # 拉取订阅节点并替换旧节点
195195# ######################################
196196refresh_subscription_dir () {
197197 local name=" $1 "
198198 local url=" $2 "
199199 local sub_dir=" $3 "
200200 local ua=" ${4:- $SUB_UA } "
201201 local hwid_val=" ${5:- $SUB_HWID } "
202+ local tmp_dir=" $sub_dir /_tmp"
202203
203204 # 临时设置全局参数供 import_sub -> run_proxylink 使用
204205 SUB_UA=" $ua "
205206 SUB_HWID=" $hwid_val "
206207
208+ # 拉取新节点到临时目录
209+ ensure_dir " $tmp_dir " " 无法创建临时目录: $tmp_dir "
210+ if ! ( import_sub " $url " " $tmp_dir " ); then
211+ log " ERROR" " 订阅拉取失败,保留旧节点: $name "
212+ rm -rf " $tmp_dir "
213+ return 1
214+ fi
215+
216+ # 拉取成功,替换旧节点
207217 clear_subscription_nodes " $sub_dir "
208- import_sub " $url " " $sub_dir "
218+ mv " $tmp_dir " /* .json " $sub_dir /" 2> /dev/null || true
219+ rm -rf " $tmp_dir "
220+
209221 write_subscription_meta " $sub_dir " " $name " " $url " " $ua " " $hwid_val "
210222}
211223
You can’t perform that action at this time.
0 commit comments