Skip to content

Commit 3126bf9

Browse files
authored
Fix GitHub fallback issues (#2771) (#2781)
- Fix broken CDN URLs (removed double /main/main/ causing 404s) - Fix local backup for root-level files (removed trailing slash requirement) - Add curl timeouts (10s max instead of 60-120s+ hangs) - Add missing IYellow color variable in fetch_lib.sh Fixes #2771
1 parent ccbf620 commit 3126bf9

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

lib.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -625,15 +625,15 @@ fi
625625
rm -f "$3"/"$2"
626626
if [ -n "$download_script_function_in_use" ]
627627
then
628-
if ! curl -sfL "$1"/"$2" -o "$3"/"$2"
628+
if ! curl -sfL --max-time 10 --connect-timeout 5 "$1"/"$2" -o "$3"/"$2"
629629
then
630630
# Try Statically.io CDN if this is a GitHub URL
631631
if [[ "$1" == *"raw.githubusercontent.com"* ]]
632632
then
633633
local cdn_url="${1/raw.githubusercontent.com/cdn.statically.io\/gh}"
634-
cdn_url="${cdn_url//\/nextcloud\/vm\//\/nextcloud\/vm\/main\/}"
635-
if curl -sfL "$cdn_url"/"$2" -o "$3"/"$2"
634+
if curl -sfL --max-time 10 --connect-timeout 5 "$cdn_url"/"$2" -o "$3"/"$2"
636635
then
636+
print_text_in_color "$IGreen" "✓ Used Statically.io CDN"
637637
return 0
638638
fi
639639
fi
@@ -650,8 +650,7 @@ fi
650650
if [[ "$1" == *"raw.githubusercontent.com"* ]]
651651
then
652652
local cdn_url="${1/raw.githubusercontent.com/cdn.statically.io\/gh}"
653-
cdn_url="${cdn_url//\/nextcloud\/vm\//\/nextcloud\/vm\/main\/}"
654-
if curl -sfL "$cdn_url"/"$2" -o "$3"/"$2"
653+
if curl -sfL --max-time 10 --connect-timeout 5 "$cdn_url"/"$2" -o "$3"/"$2"
655654
then
656655
print_text_in_color "$IGreen" "✓ Used Statically.io CDN"
657656
break
@@ -671,7 +670,7 @@ fi
671670
fi
672671
fi
673672
fi
674-
if ! curl -sfL "$1"/"$2" -o "$3"/"$2"
673+
if ! curl -sfL --max-time 10 --connect-timeout 5 "$1"/"$2" -o "$3"/"$2"
675674
then
676675
msg_box "We just tried to fetch '$1/$2', but it seems like the server for the download isn't reachable, or that a temporary error occurred. We will now try again.
677676
Please report this issue to $ISSUES"
@@ -2357,8 +2356,9 @@ try_local_backup() {
23572356

23582357
# Convert URL to local path
23592358
# https://raw.githubusercontent.com/nextcloud/vm/main/apps/script.sh -> apps/script.sh
2359+
# https://raw.githubusercontent.com/nextcloud/vm/main -> (empty, root level)
23602360
local path_part
2361-
path_part=$(echo "$url" | sed 's|https://raw.githubusercontent.com/nextcloud/vm/main/||' | sed 's|https://raw.githubusercontent.com/nextcloud/vm/master/||')
2361+
path_part=$(echo "$url" | sed 's|https://raw.githubusercontent.com/nextcloud/vm/main||' | sed 's|https://raw.githubusercontent.com/nextcloud/vm/master||' | sed 's|^/||')
23622362

23632363
# If path_part is empty, we're downloading from root
23642364
if [ -z "$path_part" ]

static/fetch_lib.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ true
44

55
IRed='\e[0;91m' # Red
66
IGreen='\e[0;92m' # Green
7+
IYellow='\e[0;93m' # Yellow
78
ICyan='\e[0;96m' # Cyan
89
Color_Off='\e[0m' # Text Reset
910
print_text_in_color() {

0 commit comments

Comments
 (0)