From 6e769f8cdd7a19d199b913d035fe0fbdc1d02b75 Mon Sep 17 00:00:00 2001 From: z4yx Date: Sun, 31 May 2020 09:11:12 +0800 Subject: [PATCH] reduce server load --- pub.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pub.sh b/pub.sh index 917931f..da11441 100755 --- a/pub.sh +++ b/pub.sh @@ -4,4 +4,5 @@ set -e BASE_URL=${MIRROR_BASE_URL:-"https://mirrors.tuna.tsinghua.edu.cn/dart-pub"} UPSTREAM_URL=${TUNASYNC_UPSTREAM_URL:-"https://pub.dartlang.org/api"} echo "From $UPSTREAM_URL to $BASE_URL" -exec /pub-cache/bin/pub_mirror --upstream "$UPSTREAM_URL" --verbose --overwrite --delete --connections 10 --concurrency 10 "$TUNASYNC_WORKING_DIR" "$BASE_URL" +if [[ $RANDOM -lt 683 ]]; then echo 'Refresh Index Files'; EXTRA=--overwrite; fi +exec /pub-cache/bin/pub_mirror --upstream "$UPSTREAM_URL" --verbose $EXTRA --delete --connections 10 --concurrency 5 "$TUNASYNC_WORKING_DIR" "$BASE_URL"