Skip to content

Commit 783d549

Browse files
some edits
ft: github copilot
1 parent 1ccf27f commit 783d549

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

udroid/src/udroid.sh

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,36 @@ GWARN() { echo -e "\e[90m${*}\e[0m";:;}
2525
INFO() { echo -e "\e[32m${*}\e[0m";:;}
2626
TITLE() { echo -e "\e[100m${*}\e[0m";:;}
2727

28+
# Fetch distro data from the internet and save it to RTCACHE
29+
# @param mode [online/offline] - online mode will fetch data from the internet, offline will use the cached data
30+
# @return distro_data [string] - path to the downloaded data
31+
2832
fetch_distro_data() {
2933

34+
# default to online mode
3035
offline_mode=false
3136
mode=$1
3237

38+
# if mode is offline, set offline_mode to true
3339
if (( mode == "offline" )); then
3440
offline_mode=true
3541
fi
3642

43+
# setup URL and path variables
3744
URL="https://raw.githubusercontent.com/RandomCoderOrg/udroid-download/main/distro-data.json"
3845
_path="${RTCACHE}/distro-data.json.cache"
3946

47+
# if the cache file exists, check for updates
4048
if [[ -f $_path ]]; then
49+
# if not in offline mode, fetch the data from the internet
4150
if ! $offline_mode; then
4251
g_spin dot "Fetching distro data.." curl -L -s -o $_path $URL || {
4352
ELOG "[${0}] failed to fetch distro data"
4453
mv $_path.old $_path
4554
}
4655
fi
4756
distro_data=$_path
57+
# otherwise, fetch the data from the internet
4858
else
4959
g_spin dot "Fetching distro data.." curl -L -s -o $_path $URL || {
5060
ELOG "[${0}] failed to fetch distro data"
@@ -639,20 +649,20 @@ list() {
639649
}
640650

641651
remove() {
642-
local _name=""
652+
local distro=""
643653
local arg=""
644654
local path=${DEFAULT_FS_INSTALL_DIR}
645655
local reset=false
646656

647657
while [ $# -gt 0 ]; do
648658
case $1 in
649-
--name) _name=$2; LOG "remove(): --name supplied to $name"; shift 2;;
659+
--name) distro=$2; LOG "remove(): --name supplied to $name"; shift 2;;
650660
--path) path=$2; LOG "remove(): looking in $path"; shift 2;;
651661
--reset) reset=true; shift 1;;
652662
*)
653-
[[ -n $_name ]] && {
654-
ELOG "remove() error: name already set to $_name"
655-
echo "--name supplied $_name"
663+
[[ -n $distro ]] && {
664+
ELOG "remove() error: name already set to $distro"
665+
echo "--name supplied $distro"
656666
}
657667

658668
if [[ -z $arg ]]; then
@@ -674,11 +684,9 @@ remove() {
674684
spinner="jump"
675685
fi
676686

677-
if [[ -z $_name ]]; then
687+
if [[ -z $distro ]]; then
678688
parser $arg "offline"
679689
distro=$name
680-
else
681-
distro=$_name
682690
fi
683691
root_fs_path=$path/$distro
684692

0 commit comments

Comments
 (0)