Skip to content

fix: Update magisk mirror check to fix 'No such file or directory' error #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 3 commits into
base: main
Choose a base branch
from

Conversation

energypatrikhu
Copy link

Updated the mount script's magisk mirror check, because when using the mount argument via the CLI, the mount script fails with a 'No such file or directory' error.

@laur89
Copy link

laur89 commented Apr 21, 2025

Haven't used magisk for a few years now, but their docs suggest current implementation is sound.

If it's really the mirror that's not existing, then either

  1. we should raise it w/ Magisk project, or;
  2. make the check safer by adding to line #58 something like:
    [ -e "${'$'}MIRROR" ] || unset MIRROR

@energypatrikhu
Copy link
Author

energypatrikhu commented Apr 21, 2025

In general what should the mirror folder contain?
In the docs it says it is used as Partition mirrors, but as for me it is empty..

Shouldn't we check if it is there AND has content?

Currently it is checked as a FILE not a directory too,
this code snippet was copied from the revanced-manager's mount script.

@oSumAtrIX
Copy link
Member

It is empty for me as well. Not sure why it is empty though. I guess we can check the contents of mirror folder. If it is empty, unset it. Please move the code block back to its original location at the bottom though.

@energypatrikhu
Copy link
Author

As a temp fix for my own project, I added a check for that, if it's good maybe I can add it to the code?
I check if the mirror folder don't exists or if it is, but it's empty

MAGISKTMP="$(magisk --path)" || MAGISKTMP=/sbin
MIRROR="$MAGISKTMP/.magisk/mirror"
if [ ! -d "$MIRROR" ] || [ -z "$(ls -A "$MIRROR" 2>/dev/null)" ]; then
    MIRROR=""
fi

@oSumAtrIX
Copy link
Member

Can't you just check if it is not empty? Because if it doesn't exist, then it will return false anyways

@energypatrikhu
Copy link
Author

Ohh that's true, then the folder check is not required here,
then using

if [ -z "$(ls -A "$MIRROR" 2>/dev/null)" ]; then

should be enough, no?

Or is there a better way to check if it's empty?

@laur89
Copy link

laur89 commented May 22, 2025

is_dir_empty() {
  find -L "$1" -mindepth 1 -maxdepth 1 -print -quit | grep -q .
  [ $? -eq 1 ]
}

@oSumAtrIX
Copy link
Member

should be enough, no?

I guess so

@energypatrikhu
Copy link
Author

Should I update the code to use the folder contents check instead of the folder exists check?

@oSumAtrIX
Copy link
Member

yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants