File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -824,7 +824,8 @@ download_mirror_score() {
824824 case " $fail_streak " in ' ' |* [!0-9]* ) fail_streak=0 ;; esac
825825
826826 if [ " $label " = " origin" ]; then
827- score=$(( score + 5 ))
827+ # Prefer GitHub mirrors by default; keep origin as the final fallback.
828+ score=$(( score - 300 ))
828829 fi
829830
830831 if [ " $success_at " -gt 0 ]; then
Original file line number Diff line number Diff line change @@ -705,7 +705,7 @@ download_subscription_yaml() {
705705 __CLASH_DOWNLOAD_UA=" $( subconverter_subscription_user_agent) " \
706706 download_subscription_file \
707707 " $url " \
708- " $out_file "
708+ " $out_file " || return 1
709709
710710 subscription_cache_store " $url " " $fmt " " $out_file " " $url "
711711 ;;
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -euo pipefail
3+
4+ SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
5+ PROJECT_DIR=" $( cd " $SCRIPT_DIR /../.." && pwd) "
6+
7+ # shellcheck source=scripts/core/common.sh
8+ source " $PROJECT_DIR /scripts/core/common.sh"
9+
10+ tmp_dir=" $( mktemp -d) "
11+ trap ' rm -rf "$tmp_dir"' EXIT
12+
13+ RUNTIME_DIR=" $tmp_dir /runtime"
14+ mkdir -p " $RUNTIME_DIR "
15+
16+ unset CLASH_GH_PROXY
17+ unset URL_GH_PROXY
18+ unset CLASH_GH_PROXY_POOL
19+
20+ url=" https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/country.mmdb"
21+ ordered_entries=" $(
22+ github_mirror_candidate_entries_ordered " $url " \
23+ | sort -t' |' -k1,1nr \
24+ | cut -d' |' -f2-
25+ ) "
26+
27+ first_label=" $( printf ' %s\n' " $ordered_entries " | head -n 1 | cut -d' |' -f1) "
28+ last_label=" $( printf ' %s\n' " $ordered_entries " | tail -n 1 | cut -d' |' -f1) "
29+
30+ if [ " $first_label " != " gh-proxy" ]; then
31+ echo " not ok - default mirror priority: first label is $first_label , expected gh-proxy" >&2
32+ printf ' %s\n' " $ordered_entries " >&2
33+ exit 1
34+ fi
35+
36+ if [ " $last_label " != " origin" ]; then
37+ echo " not ok - default mirror priority: last label is $last_label , expected origin" >&2
38+ printf ' %s\n' " $ordered_entries " >&2
39+ exit 1
40+ fi
41+
42+ echo " ok - default GitHub downloads prefer mirrors before origin"
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -euo pipefail
3+
4+ SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
5+ PROJECT_DIR=" $( cd " $SCRIPT_DIR /../.." && pwd) "
6+
7+ # shellcheck source=scripts/core/config.sh
8+ source " $PROJECT_DIR /scripts/core/config.sh"
9+
10+ tmp_dir=" $( mktemp -d) "
11+ trap ' rm -rf "$tmp_dir"' EXIT
12+
13+ RUNTIME_DIR=" $tmp_dir /runtime"
14+ mkdir -p " $RUNTIME_DIR "
15+
16+ export CLASH_AUTO_UPDATE_SUBSCRIPTIONS=" true"
17+
18+ download_subscription_file () {
19+ return 28
20+ }
21+
22+ subscription_cache_store () {
23+ echo " not ok - cache store called after failed subscription download" >&2
24+ return 0
25+ }
26+
27+ if download_subscription_yaml " https://example.invalid/sub" " $tmp_dir /sub.yaml" " manual-refresh" ; then
28+ echo " not ok - failed subscription download returned success" >&2
29+ exit 1
30+ fi
31+
32+ if [ -e " $tmp_dir /sub.yaml" ]; then
33+ echo " not ok - failed subscription download left an output file" >&2
34+ exit 1
35+ fi
36+
37+ echo " ok - failed subscription download returns failure"
You can’t perform that action at this time.
0 commit comments