Skip to content

fix: Use Magisk mirror only when it is really possible #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ internal object Constants {

chcon u:object_r:apk_data_file:s0 ${'$'}base_path

# Use Magisk mirror, if possible.
if command -v magisk &> /dev/null; then
MIRROR="${'$'}(magisk --path)/.magisk/mirror"
# Mount using Magisk mirror, if available.
MAGISKTMP="$( magisk --path )" || MAGISKTMP=/sbin
MIRROR="${'$'}MAGISKTMP/.magisk/mirror"
if [ -z "$(ls -A "${'$'}MIRROR" 2>/dev/null)" ]; then
MIRROR=""
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no reason to first set MIRROR and then unset it again. Invert the if condition and only set the variable then.

Copy link
Author

@energypatrikhu energypatrikhu May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inverting the if check means we would have to write the path twice

then this would change

MIRROR="${'$'}MAGISKTMP/.magisk/mirror"
if [ -z "$(ls -A "${'$'}MIRROR" 2>/dev/null)" ]; then
    MIRROR=""
fi

to

if [ -n "$(ls -A "${'$'}MAGISKTMP/.magisk/mirror" 2>/dev/null)" ]; then
    MIRROR="${'$'}MAGISKTMP/.magisk/mirror"
fi

as we need to check if the .magisk/mirror is not empty.

I think the how it is currently is good because it avoids the need to write the path twice,
but if you prefer the inverted logic I can change it.


mount -o bind ${'$'}MIRROR${'$'}base_path ${'$'}stock_path

# Kill the app to force it to restart the mounted APK in case it's currently running.
Expand Down