Skip to content

Commit 7e086b4

Browse files
enhance VDC detection
This now removes found vdcs from the DDC folder before checking if the folder is empty. This way we can actually properly assert if the user has installed custom vdc files, and we will also remove the original vdc files (best effort) if custom vdcs appear.
1 parent 0675f9a commit 7e086b4

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

magiskmodule/customize.sh

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
VIPERFXPACKAGE="com.pittvandewitt.viperfx"
66
SDCARD="/storage/emulated/0"
77
FOLDER="$SDCARD/Android/data/$VIPERFXPACKAGE/files"
8+
VIPERVDCFILE="ViperVDC.tar.gz"
89

910
IFS=$'\n'
1011
SEARCH_ROOT="$(magisk --path)/.magisk/mirror"/
@@ -16,25 +17,29 @@ SEARCH_ROOT="$(magisk --path)/.magisk/mirror"/
1617
# Create the scoped storage directory
1718
mkdir -p "$FOLDER"
1819

19-
[ ! -d "$FOLDER"/DDC ] && mkdir -p "$FOLDER"/DDC 2>/dev/null
20-
CUSTOM_VDC_FILES=$(find $SDCARD/ -name '*.vdc' -not -path "$SDCARD/Android/*")
20+
[ ! -f "$MODPATH"/"$VIPERVDCFILE" ] && abort "Missing $VIPERVDCFILE"
21+
mkdir -p "$FOLDER"/DDC
22+
CUSTOM_VDC_FILES=$(find $SDCARD -name '*.vdc' -not -path "$SDCARD/Android/*")
2123
[ -n "$CUSTOM_VDC_FILES" ] && CUSTOM_VDC_FOUND=true || CUSTOM_VDC_FOUND=false
22-
[ -z "$(ls "$FOLDER"/DDC 2>/dev/null)" ] && DDC_FOLDER_EMPTY=true || DDC_FOLDER_EMPTY=false
23-
if [ $DDC_FOLDER_EMPTY = true ] && [ $CUSTOM_VDC_FOUND = false ]; then
24-
ui_print "- Copying original V4A vdcs"
24+
for file in $(tar -tzf "$MODPATH"/"$VIPERVDCFILE") $CUSTOM_VDC_FILES; do
25+
file="$FOLDER"/DDC/"$file"
26+
[ -f "$file" ] && rm "$file"
27+
done
28+
[ -z "$(ls -A "$FOLDER"/DDC 2>/dev/null)" ] && VDC_FOLDER_EMPTY=true || VDC_FOLDER_EMPTY=false
29+
if $VDC_FOLDER_EMPTY && ! $CUSTOM_VDC_FOUND; then
30+
ui_print "- Copying original ViPER4Android VDCs"
2531
ui_print " Note that some of these aren't that great"
26-
ui_print " Check out here for better ones:"
27-
ui_print " https://t.me/vdcservice"
32+
ui_print " Check out https://t.me/vdcservice for better ones"
2833
mkdir -p "$FOLDER"/DDC 2>/dev/null
29-
tar -xzf "$MODPATH"/ViperVDC.tar.gz -C "$FOLDER"/DDC
34+
tar -xzf "$MODPATH"/"$VIPERVDCFILE" -C "$FOLDER"/DDC
3035
else
31-
ui_print "- Skipping Viper original vdc copy"
32-
[ $DDC_FOLDER_EMPTY = false ] && ui_print " the folder is not empty"
33-
[ $CUSTOM_VDC_FOUND = true ] && ui_print " custom vdcs have been found"
36+
ui_print "- Skipping Viper original VDC copy"
37+
! $VDC_FOLDER_EMPTY && ui_print " the folder is not empty"
38+
$CUSTOM_VDC_FOUND && ui_print " custom VDCs have been found"
3439
fi
35-
rm "$MODPATH"/vdcs.zip >/dev/null 2>&1
36-
if [ $CUSTOM_VDC_FOUND = true ]; then
37-
ui_print "- Copying custom V4A vdcs"
40+
rm "$MODPATH"/"$VIPERVDCFILE"
41+
if $CUSTOM_VDC_FOUND; then
42+
ui_print "- Copying custom VDCs"
3843
for file in $CUSTOM_VDC_FILES; do
3944
ui_print " $file"
4045
cp -f "$file" "$FOLDER"/DDC

0 commit comments

Comments
 (0)