From 578f66a5e38ed25dd8cf1bdc75ea6f13f9dfa8a7 Mon Sep 17 00:00:00 2001 From: Leonid Pliushch Date: Sun, 2 Aug 2020 01:50:34 +0300 Subject: [PATCH] termux-tools: use 5 seconds connection timeout when testing mirror availability --- packages/termux-tools/build.sh | 2 +- packages/termux-tools/pkg | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/termux-tools/build.sh b/packages/termux-tools/build.sh index aefed4e18..cbed35d64 100644 --- a/packages/termux-tools/build.sh +++ b/packages/termux-tools/build.sh @@ -1,7 +1,7 @@ TERMUX_PKG_HOMEPAGE=https://termux.com/ TERMUX_PKG_DESCRIPTION="Basic system tools for Termux" TERMUX_PKG_LICENSE="GPL-3.0" -TERMUX_PKG_VERSION=0.91 +TERMUX_PKG_VERSION=0.92 TERMUX_PKG_SKIP_SRC_EXTRACT=true TERMUX_PKG_PLATFORM_INDEPENDENT=true TERMUX_PKG_ESSENTIAL=true diff --git a/packages/termux-tools/pkg b/packages/termux-tools/pkg index 17a1de9a6..4ec9db0c6 100755 --- a/packages/termux-tools/pkg +++ b/packages/termux-tools/pkg @@ -61,9 +61,14 @@ select_mirror() { # Mirrors are rotated if 6 hours timeout has been passed or mirror is no longer accessible. if [ -n "$(find /data/data/com.termux/cache/apt/pkgcache.bin -mmin -360 2>/dev/null)" ]; then - if [ -n "${current_mirror}" ] && curl --user-agent 'Termux-PKG/1.0 mirror-checker' --head --fail --location "${current_mirror}/dists/stable/Release" >/dev/null 2>&1; then - echo "Reusing mirror: ${current_mirror}" - return + if [ -n "${current_mirror}" ]; then + echo -n "Checking availability of current mirror: " + if curl --connect-timeout 5 --user-agent 'Termux-PKG/1.0 mirror-checker' --head --fail --location "${current_mirror}/dists/stable/Release" >/dev/null 2>&1; then + echo "ok" + return + else + echo "bad" + fi fi fi @@ -72,7 +77,7 @@ select_mirror() { local w total_mirror_weight=0 for w in "${!mirrors[@]}"; do echo -n "[*] ${mirrors[$w]}: " - if curl --user-agent 'Termux-PKG/1.0 mirror-checker' --head --fail --location "${mirrors[$w]}/dists/stable/Release" >/dev/null 2>&1; then + if curl --connect-timeout 5 --user-agent 'Termux-PKG/1.0 mirror-checker' --head --fail --location "${mirrors[$w]}/dists/stable/Release" >/dev/null 2>&1; then echo "ok" total_mirror_weight=$((total_mirror_weight + w)) else