Skip to content

Commit 27f0abb

Browse files
Merge pull request #46 from ThatMG393/fix-readonly-error
try fix readonly error and fetching distro data bug
2 parents 06280b2 + c32b9b2 commit 27f0abb

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

udroid/src/udroid.sh

Lines changed: 10 additions & 7 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
}
@@ -758,9 +761,9 @@ login() {
758761
parser() {
759762
local arg=$1
760763
local mode=$2
761-
readonly suite=${arg%%:*} # readonly basically makes this public and
762-
readonly varient=${arg#*:} # unchangeable outside of this function
763-
764+
declare -g suite=${arg%%:*} # declare -g | declare globally
765+
declare -g varient=${arg#*:}
766+
764767
LOG "[USER] function args => suite=$suite varient=$varient"
765768

766769
# if TEST_MODE is set run scripts in current directory and use test.json for distro_conf

0 commit comments

Comments
 (0)