Skip to content

Commit 8dcfd4a

Browse files
committed
try fix fetching distro data
1 parent 06280b2 commit 8dcfd4a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

udroid/src/udroid.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,27 +72,30 @@ fetch_distro_data() {
7272
# setup URL and path variables
7373
URL="https://raw.githubusercontent.com/RandomCoderOrg/udroid-download/main/distro-data.json"
7474
_path="${RTCACHE}/distro-data.json.cache"
75+
mkdir -p "$RTCACHE" &> /dev/null # Just in case
7576

7677
# if the cache file exists, check for updates
7778
if [[ -f $_path ]]; then
7879
# if not in offline mode, fetch the data from the internet
7980
if ! $offline_mode; then
8081
mv $_path $_path.old
81-
g_spin dot "Fetching distro data.." curl -L -s -o $_path $URL || {
82+
g_spin dot "Fetching distro data.." curl -L -s -o $_path $URL
83+
if [[ ! -f "$_path" ]]; then # Check for file existance instead of exit code
8284
ELOG "[${0}] failed to fetch distro data"
8385
mv $_path.old $_path
8486
if $isStrictMode; then
8587
DIE "Failed to fetch distro data from: \n $URL"
8688
fi
87-
}
89+
fi
8890
fi
8991
distro_data=$_path
9092
# otherwise, fetch the data from the internet
9193
else
92-
g_spin dot "Fetching distro data.." curl -L -s -o $_path $URL || {
94+
g_spin dot "Fetching distro data.." curl -L -s -o $_path $URL
95+
if [[ ! -f "$_path" ]]; then # Check for file existance instead of exit code
9396
ELOG "[${0}] failed to fetch distro data"
9497
DIE "Failed to fetch distro data from $URL"
95-
}
98+
fi
9699
distro_data=$_path
97100
fi
98101
}

0 commit comments

Comments
 (0)