Skip to content

Commit 58ac6df

Browse files
feat: clear_cache feature
1 parent 9cdc3d1 commit 58ac6df

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

udroid/src/udroid.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -983,8 +983,20 @@ _reset() {
983983
clear_cache() {
984984
TITLE "> CLEAR CACHE"
985985
cache_size=$(du -sh -d 0 $DLCACHE | awk '{print $1}')
986-
g_spin "line" "Clearing cache" -- rm -rf $DLCACHE/*
987-
echo -e "Cache cleared ($cache_size).."
986+
987+
# check if cache is empty
988+
if [[ $cache_size == "0" ]]; then
989+
GWARN "cache is already empty"
990+
exit 0
991+
fi
992+
993+
# ask for confirmation
994+
if ask "Are you sure you want to clear cache?"; then
995+
rm -rf $DLCACHE/*
996+
echo "$cache_size cache cleared"
997+
else
998+
GWARN "cache not cleared"
999+
fi
9881000
}
9891001
####################
9901002
download() {

0 commit comments

Comments
 (0)