Skip to content

Commit 8c1dac0

Browse files
authored
Update tools.func (#5608)
1 parent 2db514f commit 8c1dac0

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

misc/tools.func

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ function fetch_and_deploy_gh_release() {
761761
local app_lc=$(echo "${app,,}" | tr -d ' ')
762762
local version_file="$HOME/.${app_lc}"
763763

764-
local api_timeout="--connect-timeout 5 --max-time 30"
764+
local api_timeout="--connect-timeout 10 --max-time 60"
765765
local download_timeout="--connect-timeout 15 --max-time 900"
766766

767767
local current_version=""
@@ -776,6 +776,14 @@ function fetch_and_deploy_gh_release() {
776776
local header=()
777777
[[ -n "${GITHUB_TOKEN:-}" ]] && header=(-H "Authorization: token $GITHUB_TOKEN")
778778

779+
# dns pre check
780+
local gh_host
781+
gh_host=$(awk -F/ '{print $3}' <<<"$api_url")
782+
if ! getent hosts "$gh_host" &>/dev/null; then
783+
msg_error "DNS resolution failed for $gh_host – check /etc/resolv.conf or networking"
784+
return 1
785+
fi
786+
779787
local max_retries=3 retry_delay=2 attempt=1 success=false resp http_code
780788

781789
while ((attempt <= max_retries)); do
@@ -785,7 +793,7 @@ function fetch_and_deploy_gh_release() {
785793
done
786794

787795
if ! $success; then
788-
msg_error "Failed to fetch release metadata after $max_retries attempts"
796+
msg_error "Failed to fetch release metadata from $api_url after $max_retries attempts"
789797
return 1
790798
fi
791799

@@ -840,14 +848,12 @@ function fetch_and_deploy_gh_release() {
840848
local assets url_match=""
841849
assets=$(echo "$json" | jq -r '.assets[].browser_download_url')
842850

843-
# If explicit filename pattern is provided (param $6), match that first
844851
if [[ -n "$6" ]]; then
845852
for u in $assets; do
846853
[[ "$u" =~ $6 || "$u" == *"$6" ]] && url_match="$u" && break
847854
done
848855
fi
849856

850-
# If no match via explicit pattern, fall back to architecture heuristic
851857
if [[ -z "$url_match" ]]; then
852858
for u in $assets; do
853859
if [[ "$u" =~ ($arch|amd64|x86_64|aarch64|arm64).*\.deb$ ]]; then
@@ -857,7 +863,6 @@ function fetch_and_deploy_gh_release() {
857863
done
858864
fi
859865

860-
# Fallback: any .deb file
861866
if [[ -z "$url_match" ]]; then
862867
for u in $assets; do
863868
[[ "$u" =~ \.deb$ ]] && url_match="$u" && break

0 commit comments

Comments
 (0)